From 352133f39bb107d669ed32416e9c3854a0f807e9 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 19 Sep 2018 17:16:39 +0530 Subject: [PATCH] cache matched defaults sets for given parameters (#6888) Merge pull request 6888 --- lib/jekyll/frontmatter_defaults.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 708a6e2d..afafec1f 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -188,8 +188,12 @@ module Jekyll # # Returns an array of hashes def matching_sets(path, type) - valid_sets.select do |set| - !set.key?("scope") || applies?(set["scope"], path, type) + @matched_set_cache ||= {} + @matched_set_cache[path] ||= {} + @matched_set_cache[path][type] ||= begin + valid_sets.select do |set| + !set.key?("scope") || applies?(set["scope"], path, type) + end end end