rails/rails — pull request #12951 by akshay-vishnoi (2013-11-19 13:53:30+00:00)
Title: avoid merging when value is blank i.e. {}

For the code given below:

```ruby
require 'rubygems'
require 'benchmark'

default_params = { 'a' => 1, 'b' => 2 }
value = {}

TIMES = 500_000
Benchmark.bmbm do |b|
b.report('old') do
TIMES.times do
default_params.merge(value).freeze if value
end
end

b.report('new') do
TIMES.times do
default_params.merge(value).freeze if value.present?
end
end
end
```

Benchmark results are:
```
Rehearsal ---------------------------------------
old 0.970000 0.010000 0.980000 ( 0.968846)
new 0.060000 0.000000 0.060000 ( 0.059513)
------------------------------ total: 1.040000sec

user system total real
old 0.940000 0.000000 0.940000 ( 0.951799)
new 0.060000 0.000000 0.060000 ( 0.060904)
```