rails/rails — pull request #17816 by byroot (2014-11-28 18:34:27+00:00)
Title: Prevent Numeric#to_s from allocating an array

`benchmark/ips` don't show any significant difference:

```ruby
Benchmark.ips do |x|
x.report('default_to_s') { 42.to_default_s }
x.report('as_to_s') { 42.to_s }
end
```

before the patch:

```
default_to_s 34.094k i/100ms
as_to_s 30.675k i/100ms
-------------------------------------------------
default_to_s 4.916M (± 9.0%) i/s - 24.241M
as_to_s 2.382M (± 9.2%) i/s - 11.749M
```

after the patch:

```
Calculating -------------------------------------
default_to_s 37.690k i/100ms
as_to_s 34.579k i/100ms
-------------------------------------------------
default_to_s 5.024M (±11.1%) i/s - 24.536M
as_to_s 3.294M (± 6.3%) i/s - 16.390M
```

That being said the standard deviation is pretty high, and `MemoryProfiler` don't seems to agree that splat args allocate an array. In any case splat args are slightly more costly than regular arguments especially since https://bugs.ruby-lang.org/issues/9622