summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-20 02:56:18 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-20 03:10:30 +0900
commitb2acae32742adf86a64ba5c0af55830bb3bddc0d (patch)
tree6bc7e24b5b739834c02cd9bcbf11ffa423461d9d /parse.y
parenta273171ca8848e85367628343ddd64ac6c0f70c1 (diff)
Reduced ID caches
NEW_GASGN and NEW_GVAR evaluate `id` argument twice.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y9
1 files changed, 6 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 6144fd1e433..477580f181e 100644
--- a/parse.y
+++ b/parse.y
@@ -11524,7 +11524,8 @@ range_op(struct parser_params *p, NODE *node, const YYLTYPE *loc)
value_expr(node);
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
if (!e_option_supplied(p)) parser_warn(p, node, "integer literal in flip-flop");
- return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."), loc), loc), loc);
+ ID lineno = rb_intern("$.");
+ return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(lineno, loc), loc), loc);
}
return cond0(p, node, COND_IN_FF, loc);
}
@@ -12795,8 +12796,10 @@ parser_append_options(struct parser_params *p, NODE *node)
if (p->do_loop) {
if (p->do_split) {
- NODE *args = NEW_LIST(NEW_GVAR(rb_intern("$;"), LOC), LOC);
- NODE *split = NEW_GASGN(rb_intern("$F"),
+ ID ifs = rb_intern("$;");
+ ID fields = rb_intern("$F");
+ NODE *args = NEW_LIST(NEW_GVAR(ifs, LOC), LOC);
+ NODE *split = NEW_GASGN(fields,
NEW_CALL(NEW_GVAR(idLASTLINE, LOC),
rb_intern("split"), args, LOC),
LOC);