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
Actions
Like0
Like0Like0Like0