aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/multibyte/utils.rb
diff options
context:
space:
mode:
authorSemyon Perepelitsa <sema@sema.in>2012-01-15 11:42:31 +0800
committerSemyon Perepelitsa <sema@sema.in>2012-01-15 11:42:31 +0800
commitd696f8de92ceb3cb38b11ec3b200b082b9578742 (patch)
treeefd81f0e921ad669e549286035aa6e6056086785 /activesupport/lib/active_support/multibyte/utils.rb
parent78ef738313d66226854b688db6ab256d078b40bb (diff)
downloadrails-d696f8de92ceb3cb38b11ec3b200b082b9578742.tar.gz
rails-d696f8de92ceb3cb38b11ec3b200b082b9578742.tar.bz2
rails-d696f8de92ceb3cb38b11ec3b200b082b9578742.zip
Pass a symbol instead of a block. This is faster and more concise.
At least Ruby 1.8.7 is required which is ok since 3.2. Benchmark: ```ruby require "benchmark" enum = 1..10_000 N = 100 Benchmark.bm do |x| x.report "inject block" do N.times do enum.inject { |sum, n| sum + n } end end x.report "inject symbol" do N.times do enum.inject(:+) end end end ``` Result: ``` user system total real inject block 0.160000 0.000000 0.160000 ( 0.179723) inject symbol 0.090000 0.000000 0.090000 ( 0.095667) ```
Diffstat (limited to 'activesupport/lib/active_support/multibyte/utils.rb')
0 files changed, 0 insertions, 0 deletions