Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: pkg/kernel/lib/transformations/closure/rewriter.dart

Issue 3008923002: Improve the performance of closure-converted code. (Closed)
Patch Set: Additional bug fixes. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/lib/transformations/closure/rewriter.dart
diff --git a/pkg/kernel/lib/transformations/closure/rewriter.dart b/pkg/kernel/lib/transformations/closure/rewriter.dart
index dd139de35033c7d783f511db162d62772b1f0a00..d3ae56ee09e91b8c4b8617e2ccc1471055aeff9b 100644
--- a/pkg/kernel/lib/transformations/closure/rewriter.dart
+++ b/pkg/kernel/lib/transformations/closure/rewriter.dart
@@ -27,6 +27,10 @@ abstract class AstRewriter {
/// Inserts an expression or statement that extends the context.
void insertExtendContext(VectorSet extender);
+ /// Inserts an expression that sets a parameter to NULL, so we don't have
+ /// unnecessary references to it.
+ void insertZeroOutParameter(VariableDeclaration parameter);
+
void _createDeclaration() {
assert(contextDeclaration == null && vectorCreation == null);
@@ -84,6 +88,11 @@ class BlockRewriter extends AstRewriter {
void insertExtendContext(VectorSet extender) {
_insertStatement(new ExpressionStatement(extender));
}
+
+ void insertZeroOutParameter(VariableDeclaration parameter) {
+ _insertStatement(
+ new ExpressionStatement(new VariableSet(parameter, new NullLiteral())));
+ }
}
class InitializerListRewriter extends AstRewriter {
@@ -112,4 +121,12 @@ class InitializerListRewriter extends AstRewriter {
init.parent = parentConstructor;
prefix.add(init);
}
+
+ @override
+ void insertZeroOutParameter(VariableDeclaration parameter) {
+ var init = new LocalInitializer(new VariableDeclaration(null,
+ initializer: new VariableSet(parameter, new NullLiteral())));
+ init.parent = parentConstructor;
+ prefix.add(init);
+ }
}
« no previous file with comments | « pkg/kernel/lib/transformations/closure/context.dart ('k') | pkg/kernel/testcases/closures/blocks.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698