Speed this up a bit

&method looks more elegant (to me) but it's 3 times slower:

```
    require 'benchmark/ips'

    ARRAY = ["test", 2, 3, 4]

    Benchmark.ips do |x|
      x.report('fast') { ARRAY.map { |r| parse_record(r) } }
      x.report('slow') { ARRAY.map &method(:parse_record) }
      x.compare!
    end
```
Comparison:
                fast:  1046992.2 i/s
                slow:   332722.5 i/s - 3.15x slower
This commit is contained in:
Jon Atack 2015-08-29 13:02:41 +02:00
parent bbae652fd0
commit d19800b480
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ module Ransack
private
def options_for(record)
record.map &method(:parse_record)
record.map { |r| parse_record(r) }
end
def parse_record(object)