Skip to content

Commit

Permalink
Reduce allocations from Liquid::Context.new
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmaroli committed Aug 30, 2019
1 parent 34083c9 commit 8750b4b
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 8750b4b

Please sign in to comment.