Skip to content

Commit

Permalink
Merge pull request Shopify#1141 from ashmaroli/reduce-context-constru…
Browse files Browse the repository at this point in the history
…ctor-allocations

Reduce allocations from `Liquid::Context.new`
  • Loading branch information
pushrax authored Aug 30, 2019
2 parents 34083c9 + 8750b4b commit 9876096
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/liquid/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ def self.build(environments: {}, outer_scope: {}, registers: {}, rethrow_errors:
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
Expand Down

0 comments on commit 9876096

Please sign in to comment.