aboutsummaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorDavid Chelimsky <dchelimsky@gmail.com>2013-08-12 19:03:53 +0200
committerDavid Chelimsky <dchelimsky@gmail.com>2013-08-12 19:22:50 +0200
commit908c0392796b945efb8c82fde5a4844788446ece (patch)
tree6a6c949c0092a023f6840baefbc0d2b56bad59c2 /tasks
parentadf3b5b79b75973b947eed37314e15274857c1a3 (diff)
downloadrails-908c0392796b945efb8c82fde5a4844788446ece.tar.gz
rails-908c0392796b945efb8c82fde5a4844788446ece.tar.bz2
rails-908c0392796b945efb8c82fde5a4844788446ece.zip
Use chop instead of singularize in Duration#inspect
Even though singularize tells a better story, chop is more than 50% faster and is all that is necessary in the case of Duration#inspect, in which all of the candidates for chopping appear in the same method and are all singularized by removing the final 's'. Benchmarks: 10000.times do 1.second.inspect end original #inspect 0.740000 0.000000 0.740000 ( 0.739065) 0.740000 0.000000 0.740000 ( 0.741458) 0.740000 0.010000 0.750000 ( 0.744011) refactored #inspect 0.330000 0.000000 0.330000 ( 0.333390) 0.330000 0.000000 0.330000 ( 0.331013) 0.320000 0.000000 0.320000 ( 0.330103) 10000.times do (1.day + 1.month + 2.minutes + 1.day).inspect end original #inspect 0.790000 0.000000 0.790000 ( 0.794624) 0.770000 0.000000 0.770000 ( 0.774577) 0.770000 0.010000 0.780000 ( 0.771295) refactored #inspect 0.390000 0.000000 0.390000 ( 0.392921) 0.400000 0.000000 0.400000 ( 0.397412) 0.370000 0.000000 0.370000 ( 0.379660)
Diffstat (limited to 'tasks')
0 files changed, 0 insertions, 0 deletions