diff options
author | Semyon Perepelitsa <sema@sema.in> | 2012-01-15 11:42:31 +0800 |
---|---|---|
committer | Semyon Perepelitsa <sema@sema.in> | 2012-01-15 11:42:31 +0800 |
commit | d696f8de92ceb3cb38b11ec3b200b082b9578742 (patch) | |
tree | efd81f0e921ad669e549286035aa6e6056086785 /actionmailer/test | |
parent | 78ef738313d66226854b688db6ab256d078b40bb (diff) | |
download | rails-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 'actionmailer/test')
0 files changed, 0 insertions, 0 deletions