Chromium Code Reviews
DescriptionPeek past balanced parens to see if they are function parameters (followed by '{' or '=>') or an expression.
The VM uses the same look-ahead technique.
This avoids the need to parse a formal parameters list first as an expression list and then convert it into formal parameters by re-parsing the expression fragments.
A map is maintained to avoid rescanning the tokens. The map is from position of open paren to token following close paren.
There is no practical measurable performance difference but there are some measurable differences on pathological inputs that contain insane numbers of parens. The map prevents these pathological inputs from having a performance effect other than a small constant factor.
The worst is insanely deep parens.
(((x))) parens 2000 deep old: 260ms, new: 640ms - mostly hash table access.
(((x+x)+(x+x))+((x+x)+(x+x))) old: 2.24, new: 2.40 - 16k expression.
f()()()... 900 calls deep, old: 480ms, new: 390ms
f = ()=>()=>()=> ... =>1; old: 870ms, new: 840ms - 100 functions deep.
frogsh: old: 1.370 new: 1.380
BUG=
TEST=
Patch Set 1 #Patch Set 2 : merge #Patch Set 3 : frogsh #Patch Set 4 : frogsh #Patch Set 5 : Cleanup #Patch Set 6 : Comments #Patch Set 7 : merge #Patch Set 8 : un-suppress the test this fixes #Patch Set 9 : expand comments #
Total comments: 4
Messages
Total messages: 3 (0 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||