Stop saving source locations unnecessarily

`node_newnode` and `parser_dispatch_delayed_token` do not use or
change `ruby_sourceline`.
This commit is contained in:
Nobuyoshi Nakada 2023-09-30 16:06:05 +09:00
Родитель 7592b07c28
Коммит 1cedecebb8
1 изменённых файлов: 1 добавлений и 19 удалений

20
parse.y
Просмотреть файл

@ -6765,9 +6765,6 @@ parser_dispatch_scan_event(struct parser_params *p, enum yytokentype t, int line
static void
parser_dispatch_delayed_token(struct parser_params *p, enum yytokentype t, int line)
{
int saved_line = p->ruby_sourceline;
const char *saved_tokp = p->lex.ptok;
debug_token_line(p, "parser_dispatch_delayed_token", line);
if (!has_delayed_token(p)) return;
@ -6775,11 +6772,7 @@ parser_dispatch_delayed_token(struct parser_params *p, enum yytokentype t, int l
RUBY_SET_YYLLOC_OF_DELAYED_TOKEN(*p->yylloc);
if (p->keep_tokens) {
p->ruby_sourceline = p->delayed.beg_line;
p->lex.ptok = p->lex.pbeg + p->delayed.beg_col;
parser_append_tokens(p, p->delayed.token, t, line);
p->ruby_sourceline = saved_line;
p->lex.ptok = saved_tokp;
}
p->delayed.token = Qnil;
@ -6817,6 +6810,7 @@ ripper_dispatch_scan_event(struct parser_params *p, enum yytokentype t)
static void
ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t)
{
/* save and adjust the location to delayed token for callbacks */
int saved_line = p->ruby_sourceline;
const char *saved_tokp = p->lex.ptok;
@ -14211,7 +14205,6 @@ args_info_empty_p(struct rb_args_info *args)
static NODE*
new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, NODE *post_args, NODE *tail, const YYLTYPE *loc)
{
int saved_line = p->ruby_sourceline;
struct rb_args_info *args = RNODE_ARGS(tail)->nd_ainfo;
if (args->forwarding) {
@ -14239,7 +14232,6 @@ new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, N
args->ruby2_keywords = 0;
#endif
p->ruby_sourceline = saved_line;
nd_set_loc(tail, loc);
return tail;
@ -14248,7 +14240,6 @@ new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, N
static NODE*
new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, const YYLTYPE *kw_rest_loc)
{
int saved_line = p->ruby_sourceline;
NODE *node = NEW_ARGS(0, &NULL_LOC);
struct rb_args_info *args = ZALLOC(struct rb_args_info);
RNODE_ARGS(node)->nd_ainfo = args;
@ -14301,7 +14292,6 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
args->kw_rest_arg = NEW_DVAR(kw_rest_arg, kw_rest_loc);
}
p->ruby_sourceline = saved_line;
return node;
}
@ -14339,8 +14329,6 @@ new_array_pattern(struct parser_params *p, NODE *constant, NODE *pre_arg, NODE *
static NODE*
new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc)
{
int saved_line = p->ruby_sourceline;
if (has_rest) {
rest_arg = rest_arg ? rest_arg : NODE_SPECIAL_NO_NAME_REST;
}
@ -14349,7 +14337,6 @@ new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, NO
}
NODE *node = NEW_ARYPTN(pre_args, rest_arg, post_args, loc);
p->ruby_sourceline = saved_line;
return node;
}
@ -14364,13 +14351,10 @@ new_find_pattern(struct parser_params *p, NODE *constant, NODE *fndptn, const YY
static NODE*
new_find_pattern_tail(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc)
{
int saved_line = p->ruby_sourceline;
pre_rest_arg = pre_rest_arg ? pre_rest_arg : NODE_SPECIAL_NO_NAME_REST;
post_rest_arg = post_rest_arg ? post_rest_arg : NODE_SPECIAL_NO_NAME_REST;
NODE *node = NEW_FNDPTN(pre_rest_arg, args, post_rest_arg, loc);
p->ruby_sourceline = saved_line;
return node;
}
@ -14384,7 +14368,6 @@ new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YY
static NODE*
new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc)
{
int saved_line = p->ruby_sourceline;
NODE *node, *kw_rest_arg_node;
if (kw_rest_arg == idNil) {
@ -14399,7 +14382,6 @@ new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, co
node = NEW_HSHPTN(0, kw_args, kw_rest_arg_node, loc);
p->ruby_sourceline = saved_line;
return node;
}