Provide a better default hash for tracking liquid stats (#6417)

Merge pull request 6417
This commit is contained in:
Matt Rogers 2017-10-07 18:54:32 -05:00 committed by jekyllbot
parent 4a2ab9247c
commit d48412401a
1 changed files with 6 additions and 4 deletions

View File

@ -22,19 +22,16 @@ module Jekyll
)
LiquidRenderer::File.new(self, filename).tap do
@stats[filename] ||= {}
@stats[filename][:count] ||= 0
@stats[filename] ||= new_profile_hash
@stats[filename][:count] += 1
end
end
def increment_bytes(filename, bytes)
@stats[filename][:bytes] ||= 0
@stats[filename][:bytes] += bytes
end
def increment_time(filename, time)
@stats[filename][:time] ||= 0.0
@stats[filename][:time] += time
end
@ -45,5 +42,10 @@ module Jekyll
def self.format_error(e, path)
"#{e.message} in #{path}"
end
private
def new_profile_hash
Hash.new { |hash, key| hash[key] = 0 }
end
end
end