From d19800b480f6b48792a82ae392dccbeb1306df92 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sat, 29 Aug 2015 13:02:41 +0200 Subject: [PATCH] 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 --- lib/ransack/helpers/form_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ransack/helpers/form_helper.rb b/lib/ransack/helpers/form_helper.rb index f17c617..f2a1a73 100644 --- a/lib/ransack/helpers/form_helper.rb +++ b/lib/ransack/helpers/form_helper.rb @@ -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)