From 0fa075b87969ed82a41080f1b0bbe0e1ba9a7f23 Mon Sep 17 00:00:00 2001 From: Florian Weingarten Date: Wed, 15 Oct 2014 19:26:39 +0000 Subject: [PATCH] Use pop over shift to avoid reverse --- lib/liquid/tags/if.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/liquid/tags/if.rb b/lib/liquid/tags/if.rb index 60bd634b..a812b10e 100644 --- a/lib/liquid/tags/if.rb +++ b/lib/liquid/tags/if.rb @@ -57,15 +57,15 @@ module Liquid end def lax_parse(markup) - expressions = markup.scan(ExpressionsAndOperators).reverse - raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.shift =~ Syntax + expressions = markup.scan(ExpressionsAndOperators) + raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.pop =~ Syntax condition = Condition.new($1, $2, $3) while not expressions.empty? - operator = (expressions.shift).to_s.strip + operator = expressions.pop.to_s.strip - raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.shift.to_s =~ Syntax + raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless expressions.pop.to_s =~ Syntax new_condition = Condition.new($1, $2, $3) raise(SyntaxError.new(options[:locale].t("errors.syntax.if".freeze))) unless BOOLEAN_OPERATORS.include?(operator)