Skip to content
Permalink
Browse files

Reduce Array objects generated from utility method (#7749)

Merge pull request 7749
  • Loading branch information...
ashmaroli authored and jekyllbot committed Jul 12, 2019
1 parent 77b6033 commit 135ebe26604e697fa8766deec8fb672e592e405b
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/jekyll/utils.rb
@@ -68,11 +68,14 @@ def duplicable?(obj)
#
# Returns an array
def pluralized_array_from_hash(hash, singular_key, plural_key)
[].tap do |array|
value = value_from_singular_key(hash, singular_key)
value ||= value_from_plural_key(hash, plural_key)
array << value
end.flatten.compact
array = []
value = value_from_singular_key(hash, singular_key)
value ||= value_from_plural_key(hash, plural_key)

array << value
array.flatten!
array.compact!
array
end

def value_from_singular_key(hash, key)

0 comments on commit 135ebe2

Please sign in to comment.
You can’t perform that action at this time.