Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let RangeLookup handle all ranges #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ source 'https://rubygems.org'

gemspec

gem 'liquid', github: 'Shopify/liquid', branch: 'master'

gem 'liquid', github: 'Shopify/liquid', branch: 'range-optimization'

group :test do
gem 'spy', '0.4.1'
Expand Down
8 changes: 2 additions & 6 deletions ext/liquid_c/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "parser.h"
#include "lexer.h"

static VALUE cLiquidRangeLookup, cLiquidVariableLookup, cRange, vLiquidExpressionLiterals;
static VALUE cLiquidRangeLookup, cLiquidVariableLookup, vLiquidExpressionLiterals;
static ID idToI, idEvaluate;

void init_parser(parser_t *p, const char *str, const char *end)
Expand Down Expand Up @@ -78,10 +78,7 @@ static VALUE parse_range(parser_t *p)
args[1] = parse_expression(p);
parser_must_consume(p, TOKEN_CLOSE_ROUND);

if (rb_respond_to(args[0], idEvaluate) || rb_respond_to(args[1], idEvaluate))
return rb_class_new_instance(2, args, cLiquidRangeLookup);

return rb_class_new_instance(2, args, cRange);
return rb_class_new_instance(2, args, cLiquidRangeLookup);
}

static VALUE parse_variable(parser_t *p)
Expand Down Expand Up @@ -184,7 +181,6 @@ void init_liquid_parser(void)
idEvaluate = rb_intern("evaluate");

cLiquidRangeLookup = rb_const_get(mLiquid, rb_intern("RangeLookup"));
cRange = rb_const_get(rb_cObject, rb_intern("Range"));
cLiquidVariableLookup = rb_const_get(mLiquid, rb_intern("VariableLookup"));

VALUE cLiquidExpression = rb_const_get(mLiquid, rb_intern("Expression"));
Expand Down