From 2eb318a929713836e533834323062a8cf50b9645 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 22 Oct 2014 01:43:46 -0700 Subject: [PATCH] Replace costly Hash#fetch with arity=2 with arity=1 + block. --- lib/jekyll/page.rb | 2 +- lib/jekyll/post.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index d045b7c2..dcbd3ac5 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -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 diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 293e2c5d..f816e165 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -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