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

Set @line_number directly on the Liquid::ParseContext #100

Merged
merged 1 commit into from
Oct 23, 2020
Merged
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
4 changes: 1 addition & 3 deletions ext/liquid_c/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ static ID
intern_is_blank,
intern_parse,
intern_square_brackets,
intern_set_line_number,
intern_unknown_tag_in_liquid_tag,
intern_ivar_nodelist;

Expand Down Expand Up @@ -88,7 +87,7 @@ static tag_markup_t internal_block_body_parse(block_body_t *body, parse_context_
while (true) {
int token_start_line_number = tokenizer->line_number;
if (token_start_line_number != 0) {
rb_funcall(parse_context->ruby_obj, intern_set_line_number, 1, UINT2NUM(token_start_line_number));
rb_ivar_set(parse_context->ruby_obj, id_ivar_line_number, UINT2NUM(token_start_line_number));
}
tokenizer_next(tokenizer, &token);

Expand Down Expand Up @@ -409,7 +408,6 @@ void init_liquid_block()
intern_is_blank = rb_intern("blank?");
intern_parse = rb_intern("parse");
intern_square_brackets = rb_intern("[]");
intern_set_line_number = rb_intern("line_number=");
intern_unknown_tag_in_liquid_tag = rb_intern("unknown_tag_in_liquid_tag");
intern_ivar_nodelist = rb_intern("@nodelist");

Expand Down
2 changes: 2 additions & 0 deletions ext/liquid_c/liquid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ID id_to_liquid;
ID id_to_s;
ID id_call;
ID id_compile_evaluate;
ID id_ivar_line_number;

VALUE mLiquid, mLiquidC, cLiquidVariable, cLiquidTemplate, cLiquidBlockBody;
VALUE cLiquidVariableLookup, cLiquidRangeLookup;
Expand All @@ -36,6 +37,7 @@ void Init_liquid_c(void)
id_to_s = rb_intern("to_s");
id_call = rb_intern("call");
id_compile_evaluate = rb_intern("compile_evaluate");
id_ivar_line_number = rb_intern("@line_number");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason id_ivar_line_number is declared in liquid.c rather than block.c? Is it/will it be used anywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will let me re-use the same ID for re-using with rb_attr_get, which I will need for Liquid::Assign.compile in #96


utf8_encoding = rb_utf8_encoding();
utf8_encoding_index = rb_enc_to_index(utf8_encoding);
Expand Down
1 change: 1 addition & 0 deletions ext/liquid_c/liquid.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern ID id_to_liquid;
extern ID id_to_s;
extern ID id_call;
extern ID id_compile_evaluate;
extern ID id_ivar_line_number;

extern VALUE mLiquid, mLiquidC, cLiquidVariable, cLiquidTemplate, cLiquidBlockBody;
extern VALUE cLiquidVariableLookup, cLiquidRangeLookup;
Expand Down