Commit f3c1936
committed
Tweak array construction in
This results in a performance increase, and reduced object allocation, when normalizing keys -
```ruby
report = Benchmark.ips do |x|
x.report("concat") do
ex = []
ex.concat ['foo']
ex.concat ['bar', 'baz']
ex.concat ['quix']
ex
end
x.report("splat") do
[
*['foo'],
*['bar', 'baz'],
*['quix']
]
end
x.compare!
Warming up --------------------------------------
concat 129.103k i/100ms
splat 243.963k i/100ms
Calculating -------------------------------------
concat 1.176M (± 9.7%) i/s - 5.810M in 5.009251s
splat 2.435M (±11.8%) i/s - 11.954M in 5.019257s
Comparison:
splat: 2434746.6 i/s
concat: 1176432.3 i/s - 2.07x (± 0.00) slower
```normalize_keys
1 parent a1dc424 commit f3c1936
1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| |||
0 commit comments