Merge pull request #1141 from ashmaroli/reduce-context-constructor-allocations

Reduce allocations from `Liquid::Context.new`
This commit is contained in:
Justin Li
2019-08-30 12:53:50 -04:00
committed by GitHub

View File

@@ -21,8 +21,10 @@ module Liquid
end
def initialize(environments = {}, outer_scope = {}, registers = {}, rethrow_errors = false, resource_limits = nil, static_registers = {}, static_environments = {})
@environments = [environments].flatten
@static_environments = [static_environments].flatten.map(&:freeze).freeze
@environments = [environments]
@environments.flatten!
@static_environments = [static_environments].flat_map(&:freeze).freeze
@scopes = [(outer_scope || {})]
@registers = registers
@static_registers = static_registers.freeze