Replace costly Hash#fetch with arity=2 with arity=1 + block.

This commit is contained in:
Parker Moore 2014-10-22 01:43:46 -07:00
parent ab3f27e674
commit 2eb318a929
2 changed files with 4 additions and 4 deletions

View File

@ -126,7 +126,7 @@ module Jekyll
#
# Returns the path to the source file
def path
data.fetch('path', relative_path.sub(/\A\//, ''))
data.fetch('path') { relative_path.sub(/\A\//, '') }
end
# The path to the page source file, relative to the site source

View File

@ -108,14 +108,14 @@ module Jekyll
#
# Returns excerpt string.
def excerpt
data.fetch('excerpt', extracted_excerpt.to_s)
data.fetch('excerpt') { extracted_excerpt.to_s }
end
# Public: the Post title, from the YAML Front-Matter or from the slug
#
# Returns the post title
def title
data.fetch("title", titleized_slug)
data.fetch("title") { titleized_slug }
end
# Turns the post slug into a suitable title
@ -130,7 +130,7 @@ module Jekyll
#
# Returns the path to the file relative to the site source
def path
data.fetch('path', relative_path.sub(/\A\//, ''))
data.fetch('path') { relative_path.sub(/\A\//, '') }
end
# The path to the post source file, relative to the site source