aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/bin/test
diff options
context:
space:
mode:
authorViktar Basharymau <viktar.basharymau@gmail.com>2016-01-02 18:42:15 +0300
committerViktar Basharymau <viktar.basharymau@gmail.com>2016-01-02 19:34:40 +0300
commit20aef99f7bd136f156bf4b3808626398013f22f5 (patch)
treea062ed5b066c12ed7edd3ca1663961ebdc02d782 /activesupport/bin/test
parenta0a62da235e8d87795d6cef6613ddf440386b366 (diff)
downloadrails-20aef99f7bd136f156bf4b3808626398013f22f5.tar.gz
rails-20aef99f7bd136f156bf4b3808626398013f22f5.tar.bz2
rails-20aef99f7bd136f156bf4b3808626398013f22f5.zip
Replace x.times.map{} with Array.new(x){}
The former is slightly more readable, performant and has fewer method calls. ```ruby Benchmark.ips do |x| x.report('times.map') { 5.times.map{} } x.report('Array.new') { Array.new(5){} } x.compare! end __END__ Calculating ------------------------------------- times.map 21.188k i/100ms Array.new 30.449k i/100ms ------------------------------------------------- times.map 311.613k (± 3.5%) i/s - 1.568M Array.new 590.374k (± 1.2%) i/s - 2.954M Comparison: Array.new: 590373.6 i/s times.map: 311612.8 i/s - 1.89x slower ```
Diffstat (limited to 'activesupport/bin/test')
0 files changed, 0 insertions, 0 deletions