Actions
Bug #15018
closedNODE_ARGSCAT is not parsed properly
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-08-22 trunk 64505) [x86_64-linux]
Description
Instead of wrapping following arguments in one list, current implementation creates multiple list wrapping only 2 elements.
e.g.
for
[*args,1,2,3,4,5,6]
Expected AST:
NODE_ARGSCAT---nd_head-->NODE_SPLAT(args)
|
|---nd_body-->NODE_ARRAY(1,2,3,4,5,6)
Current AST:
NODE_ARGSCAT---nd_head-->NODE_ARGSCAT--nd_head-->NODE_ARGSCAT--nd_head-->NODE_SPLAT(args)
| | |
| | |---nd_body-->NODE_ARRAY(1,2)
| |
| |---nd_body-->NODE_ARRAY(3,4)
|
|---nd_body-->NODE_ARRAY(5,6)
Current Implementation result into something like
args + [1,2] + [3,4] + [5,6]
instead of
args + [1,2,3,4,5,6]
Benchmark result
With patch:
user system total real
argscat 0.556000 0.000000 0.556000 ( 0.553981)
argscat_multiple 2.372000 0.000000 2.372000 ( 2.373701)
Trunk:
user system total real
argscat 1.656000 0.000000 1.656000 ( 1.655868)
argscat_multiple 6.232000 0.000000 6.232000 ( 6.234846)
Implementation:
https://github.com/ruby/ruby/pull/1940
Files
Updated by chopraanmol1 (Anmol Chopra) about 6 years ago
- Description updated (diff)
Updated by mame (Yusuke Endoh) about 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r64510.
parse.y (arg_append): support NODE_ARGSCAT case
Because of the lack of this case, [*ary,1,2,3,4,5,6]
was parsed into
an inefficient AST like ary + [1,2] + [3,4] + [5,6]
.
A patch from Anmol Chopra anmolchopra@rocketbox.in.
Fixes [Bug #15018].
Updated by mame (Yusuke Endoh) about 6 years ago
Good catch! I've committed it. Thank you!
Actions
Like0
Like0Like0Like0