dart2js cps: Eliminate unary string concatenation.
BUG= R=kmillikin@google.com Review URL: https://codereview.chromium.org/1563983002 .
This commit is contained in:
@@ -2073,6 +2073,11 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
||||
if (argumentsWereRemoved) {
|
||||
node.arguments.removeWhere((ref) => ref == null);
|
||||
}
|
||||
if (node.arguments.length == 1) {
|
||||
Primitive input = node.arguments[0].definition;
|
||||
node.replaceUsesWith(input);
|
||||
input.useElementAsHint(node.hint);
|
||||
}
|
||||
// TODO(asgerf): Rebalance nested StringConcats that arise from
|
||||
// rewriting the + operator to StringConcat.
|
||||
break;
|
||||
|
||||
@@ -130,11 +130,10 @@ main() {
|
||||
print(list);
|
||||
}""", r"""
|
||||
function() {
|
||||
var list = [1, 2, 3], res, v0;
|
||||
var list = [1, 2, 3], v0;
|
||||
list[1] = 6;
|
||||
if (!(typeof (res = C.JSArray_methods.toString$0(list)) === "string"))
|
||||
if (!(typeof (v0 = P.IterableBase_iterableToFullString(list, "[", "]")) === "string"))
|
||||
throw H.wrapException(H.argumentErrorValue(list));
|
||||
v0 = res;
|
||||
if (typeof dartPrint == "function")
|
||||
dartPrint(v0);
|
||||
else if (typeof console == "object" && typeof console.log != "undefined")
|
||||
|
||||
Reference in New Issue
Block a user