From b019d441b99ae992222f17ffb19e73cb5c23193a Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 13 Apr 2020 21:12:30 +0530 Subject: [PATCH] Reduce allocations of instance-agnostic objects (#376) Merge pull request 376 --- lib/jekyll-seo-tag/json_ld_drop.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-seo-tag/json_ld_drop.rb b/lib/jekyll-seo-tag/json_ld_drop.rb index 57b4c25..3bd1d46 100644 --- a/lib/jekyll-seo-tag/json_ld_drop.rb +++ b/lib/jekyll-seo-tag/json_ld_drop.rb @@ -20,6 +20,9 @@ module Jekyll private :type private :logo + VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze + private_constant :VALID_ENTITY_TYPES + # page_drop should be an instance of Jekyll::SeoTag::Drop def initialize(page_drop) @mutations = {} @@ -27,7 +30,7 @@ module Jekyll end def fallback_data - { + @fallback_data ||= { "@context" => "https://schema.org", } end @@ -66,7 +69,7 @@ module Jekyll end def main_entity - return unless %w(BlogPosting CreativeWork).include?(type) + return unless VALID_ENTITY_TYPES.include?(type) { "@type" => "WebPage",