Actions
Bug #13330
closedArray.include? is slow for symbols
Description
Looking at the code I noticed that [:test].include?(:test) goes through a general path instead using an optimised version making searching slower than for strings:
Benchmark available at https://github.com/pawelniewie/benchmark-set-array-contains/blob/master/ruby/array_include.rb
Comparison:
array: 1332567.6 i/s
array symbols: 1154135.9 i/s - 1.15x slower
I created a fix for that, after changes you get following results:
Comparison:
array symbols: 1630417.3 i/s
array: 1372269.7 i/s - 1.19x slower
Updated by pawelniewie (Pawel Niewiadomski) about 7 years ago
Created PR with a fix https://github.com/ruby/ruby/pull/1540
Updated by ko1 (Koichi Sasada) almost 7 years ago
- Status changed from Open to Assigned
- Assignee set to ko1 (Koichi Sasada)
Thank you. I'll commit it.
Updated by ko1 (Koichi Sasada) almost 7 years ago
- Status changed from Assigned to Closed
Applied in changeset trunk|r58895.
Symbol support for opt_eq_func.
- vm_insnhelper.c (opt_eq_func): optimize for symbol comparison.
[Bug #13330] [fix GH-1540]
Actions
Like0
Like0Like0Like0