Avoid introducing js.Parameters in constructor body

Use the Parameter name in the template so that it is converted into a
VariableUse.

This change fixes some double-counting in the function parameter /
local variable minifier which made the --fast-startup constructors
'miss' using some minified names.

I believe the 'missed' names is a regression.

Saves 50k (0.4%) on one large app.

Change-Id: Ib7597f5c474ef285b082697e368667dbac23931b
Reviewed-on: https://dart-review.googlesource.com/30720
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams 2017-12-20 06:09:25 +00:00 committed by commit-bot@chromium.org
parent 2930223f13
commit 72736aff0d
2 changed files with 4 additions and 6 deletions

View file

@ -756,15 +756,15 @@ class FragmentEmitter {
for (Field field in cls.fields) { for (Field field in cls.fields) {
js.Parameter parameter = new js.Parameter('t${parameters.length}'); js.Parameter parameter = new js.Parameter('t${parameters.length}');
parameters.add(parameter); parameters.add(parameter);
statements statements.add(
.add(js.js.statement('#.# = #', [thisRef, field.name, parameter])); js.js.statement('#.# = #', [thisRef, field.name, parameter.name]));
} }
if (cls.hasRtiField) { if (cls.hasRtiField) {
js.Parameter parameter = new js.Parameter('t${parameters.length}'); js.Parameter parameter = new js.Parameter('t${parameters.length}');
parameters.add(parameter); parameters.add(parameter);
statements.add(js.js statements.add(js.js.statement(
.statement('#.# = #', [thisRef, namer.rtiFieldJsName, parameter])); '#.# = #', [thisRef, namer.rtiFieldJsName, parameter.name]));
} }
return js.js('function #(#) { # }', [name, parameters, statements]); return js.js('function #(#) { # }', [name, parameters, statements]);

View file

@ -287,7 +287,6 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
Statement toStatement(item) { Statement toStatement(item) {
if (item is Statement) return item; if (item is Statement) return item;
if (item is Expression) return item.toStatement(); if (item is Expression) return item.toStatement();
;
return error('Interpolated value #$nameOrPosition is not ' return error('Interpolated value #$nameOrPosition is not '
'a Statement or List of Statements: $value'); 'a Statement or List of Statements: $value');
} }
@ -368,7 +367,6 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
if (value is bool) return value; if (value is bool) return value;
if (value is Expression) return value; if (value is Expression) return value;
if (value is String) return convertStringToVariableUse(value); if (value is String) return convertStringToVariableUse(value);
;
error('Interpolated value #$nameOrPosition ' error('Interpolated value #$nameOrPosition '
'is not an Expression: $value'); 'is not an Expression: $value');
}; };