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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1195573003: dart2js cps: Refactor and optimize string concatenations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert doc comment change Created 5 years, 6 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/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index b95819bf05b32f69d7e06f6aa5c57e9683f57dd0..7042defa0147a93247b1c3aa7e22891a46c4a5e2 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -171,31 +171,6 @@ class CodeGenerator extends tree_ir.StatementVisitor
}
@override
- js.Expression visitConcatenateStrings(tree_ir.ConcatenateStrings node) {
- js.Expression addStrings(js.Expression left, js.Expression right) {
- return new js.Binary('+', left, right);
- }
-
- js.Expression toString(tree_ir.Expression input) {
- bool useDirectly = input is tree_ir.Constant &&
- (input.value.isString ||
- input.value.isInt ||
- input.value.isBool);
- js.Expression value = visitExpression(input);
- if (useDirectly) {
- return value;
- } else {
- Element convertToString = glue.getStringConversion();
- registry.registerStaticUse(convertToString);
- js.Expression access = glue.staticFunctionAccess(convertToString);
- return (new js.Call(access, <js.Expression>[value]));
- }
- }
-
- return node.arguments.map(toString).reduce(addStrings);
- }
-
- @override
js.Expression visitConditional(tree_ir.Conditional node) {
return new js.Conditional(
visitExpression(node.condition),
@@ -739,6 +714,9 @@ class CodeGenerator extends tree_ir.StatementVisitor
return new js.Binary('>', args[0], args[1]);
case BuiltinOperator.NumGe:
return new js.Binary('>=', args[0], args[1]);
+ case BuiltinOperator.StringConcatenate:
+ if (args.isEmpty) return js.string('');
+ return args.reduce((e1,e2) => new js.Binary('+', e1, e2));
case BuiltinOperator.StrictEq:
return new js.Binary('===', args[0], args[1]);
case BuiltinOperator.StrictNeq:
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698