From bf18b27e2a2acd91114b3f5bfdd95a060098bc36 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Wed, 4 Nov 2020 21:01:00 +0530 Subject: [PATCH] Reduce array allocations from merging categories (#8453) Merge pull request 8453 --- lib/jekyll/document.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index a5f8a787..cd922dd6 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -453,7 +453,10 @@ module Jekyll def merge_categories!(other) if other.key?("categories") && !other["categories"].nil? other["categories"] = other["categories"].split if other["categories"].is_a?(String) - other["categories"] = (data["categories"] || []) | other["categories"] + + if data["categories"].is_a?(Array) + other["categories"] = data["categories"] | other["categories"] + end end end