1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

#none? should be much faster than select#empty?

∴ rake benchmarks:select_empty_versus_none
Calculating -------------------------------------
       select.empty?     2.581k i/100ms
               none?    12.755k i/100ms
-------------------------------------------------
       select.empty?     28.826k (± 6.3%) i/s -    144.536k
               none?    268.873k (± 5.9%) i/s -      1.352M

Comparison:
               none?:   268873.0 i/s
       select.empty?:    28826.3 i/s - 9.33x slower
This commit is contained in:
Jon Atack 2014-12-10 19:28:08 +01:00
parent 76191612ad
commit 14bc115028

View file

@ -136,8 +136,7 @@ module Ransack
else
stripped_name
.split(/_and_|_or_/)
.select { |n| !@context.attribute_method?(n) }
.empty?
.none? { |n| !@context.attribute_method?(n) }
end
end