From db00fb238be221f58414d5b5763321706e262f24 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Tue, 24 Nov 2020 16:30:52 +0900 Subject: Optimize `presym_find` Chang to compare string length first. ### Benchmark #### Code * https://github.com/shuujii/mruby-presym_find-benchmark #### Result ```console Previous: 10.240772M i/s (25M times in 2.441222s) New: 16.412985M i/s (25M times in 1.523184s) ``` --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 1a8663400..1fc0de999 100644 --- a/Rakefile +++ b/Rakefile @@ -192,7 +192,7 @@ file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do src.scan(/[ \(\[\{]:'([^']+)'/) ] end - symbols = (symbols+csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort.grep_v(/#/).map{|x| x.gsub("\n", '\n')} + symbols = (symbols+csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.grep_v(/#/).map{|x| x.gsub("\n", '\n')}.sort_by!{|x| [x.bytesize, x]} presyms = File.readlines(presym_file) rescue [] presyms.each{|x| x.chomp!} if presyms != symbols -- cgit v1.2.3