From: ko1@... Date: 2017-05-19T06:42:37+00:00 Subject: [ruby-core:81249] [Ruby trunk Bug#13330][Assigned] Array.include? is slow for symbols Issue #13330 has been updated by ko1 (Koichi Sasada). Status changed from Open to Assigned Assignee set to ko1 (Koichi Sasada) Thank you. I'll commit it. ---------------------------------------- Bug #13330: Array.include? is slow for symbols https://bugs.ruby-lang.org/issues/13330#change-64909 * Author: pawelniewie (Pawel Niewiadomski) * Status: Assigned * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: * ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- 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 -- https://bugs.ruby-lang.org/ Unsubscribe: