fasterer: hash#fetch with block is faster

hash#fetch with block is faster than hash#fetch with
second parameter
This commit is contained in:
Reinier Balt 2015-08-19 14:49:52 +02:00
parent ddd9c07d3b
commit 0d224a5fe9

View file

@ -448,7 +448,7 @@ class StatsController < ApplicationController
end
def three_month_avg(set, i)
(set.fetch(i,0) + set.fetch(i+1,0) + set.fetch(i+2,0)) / 3.0
(set.fetch(i){ 0 } + set.fetch(i+1){ 0 } + set.fetch(i+2){ 0 }) / 3.0
end
def set_three_month_avg(set,upper_bound)