Merge pull request #1137 from Shopify/remove-lazy-stacks

Remove lazy load stacks
This commit is contained in:
Mike Angell
2019-09-16 12:14:14 +10:00
committed by GitHub
6 changed files with 40 additions and 64 deletions
+2 -16
View File
@@ -35,8 +35,6 @@ module Liquid
@base_scope_depth = 0
squash_instance_assigns_with_environments
@this_stack_used = false
self.exception_renderer = Template.default_exception_renderer
if rethrow_errors
self.exception_renderer = ->(e) { raise }
@@ -122,19 +120,11 @@ module Liquid
# end
#
# context['var] #=> nil
def stack(new_scope = nil)
old_stack_used = @this_stack_used
if new_scope
def stack(new_scope = {})
push(new_scope)
@this_stack_used = true
else
@this_stack_used = false
end
yield
ensure
pop if @this_stack_used
@this_stack_used = old_stack_used
pop
end
# Creates a new context inheriting resource limits, filters, environment etc.,
@@ -162,10 +152,6 @@ module Liquid
# Only allow String, Numeric, Hash, Array, Proc, Boolean or <tt>Liquid::Drop</tt>
def []=(key, value)
unless @this_stack_used
@this_stack_used = true
push({})
end
@scopes[0][key] = value
end
-2
View File
@@ -39,7 +39,6 @@ module Liquid
end
def render_to_output_buffer(context, output)
context.stack do
execute_else_block = true
@blocks.each do |block|
@@ -50,7 +49,6 @@ module Liquid
block.attachment.render_to_output_buffer(context, output)
end
end
end
output
end
-2
View File
@@ -34,7 +34,6 @@ module Liquid
def render_to_output_buffer(context, output)
context.registers[:cycle] ||= {}
context.stack do
key = context.evaluate(@name)
iteration = context.registers[:cycle][key].to_i
@@ -51,7 +50,6 @@ module Liquid
iteration += 1
iteration = 0 if iteration >= @variables.size
context.registers[:cycle][key] = iteration
end
output
end
-2
View File
@@ -40,13 +40,11 @@ module Liquid
end
def render_to_output_buffer(context, output)
context.stack do
@blocks.each do |block|
if block.evaluate(context)
return block.attachment.render_to_output_buffer(context, output)
end
end
end
output
end
-2
View File
@@ -1,7 +1,6 @@
module Liquid
class Ifchanged < Block
def render_to_output_buffer(context, output)
context.stack do
block_output = ''
super(context, block_output)
@@ -9,7 +8,6 @@ module Liquid
context.registers[:ifchanged] = block_output
output << block_output
end
end
output
end
-2
View File
@@ -7,7 +7,6 @@ module Liquid
#
class Unless < If
def render_to_output_buffer(context, output)
context.stack do
# First condition is interpreted backwards ( if not )
first_block = @blocks.first
unless first_block.evaluate(context)
@@ -20,7 +19,6 @@ module Liquid
return block.attachment.render_to_output_buffer(context, output)
end
end
end
output
end