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

Unified Diff: dart/lib/compiler/implementation/lib/mockimpl.dart

Issue 10553007: Remove support for String operator + from dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update co19 status Created 8 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: dart/lib/compiler/implementation/lib/mockimpl.dart
diff --git a/dart/lib/compiler/implementation/lib/mockimpl.dart b/dart/lib/compiler/implementation/lib/mockimpl.dart
index b6f18055e7e65737ee6033ffd3f0a97f538179ab..fd6d6e1c978213ff68b52e2e82d22f112418dcf2 100644
--- a/dart/lib/compiler/implementation/lib/mockimpl.dart
+++ b/dart/lib/compiler/implementation/lib/mockimpl.dart
@@ -142,27 +142,35 @@ class StringBase {
static String join(List<String> strings, String separator) {
checkNull(strings);
checkNull(separator);
- var result = "";
- var first = true;
- for (var string in strings) {
- checkNull(string);
- if (string is !String) throw new IllegalArgumentException(string);
- if (!first) result += separator; // TODO(ahe): Use string buffer.
- result += string; // TODO(ahe): Use string buffer.
- first = false;
- }
- return result;
+ if (separator is !String) throw new IllegalArgumentException(separator);
+ return stringJoinUnchecked(_toJsStringArray(strings), separator);
}
static String concatAll(List<String> strings) {
+ return stringJoinUnchecked(_toJsStringArray(strings), "");
+ }
+
+ static List _toJsStringArray(List<String> strings) {
checkNull(strings);
- var result = "";
- for (var string in strings) {
- checkNull(string);
- if (string is !String) throw new IllegalArgumentException(string);
- result = '$result$string'; // TODO(ahe): Use string buffer.
+ var array;
+ final length = strings.length;
+ if (isJsArray(strings)) {
+ array = strings;
+ for (int i = 0; i < length; i++) {
+ final string = strings[i];
+ checkNull(string);
Lasse Reichstein Nielsen 2012/06/18 09:25:32 Do we really want to throw a NPE instead of an IAE
ahe 2012/06/18 10:39:16 This is what the other implementation does. I cann
+ if (string is !String) throw new IllegalArgumentException(string);
+ }
+ } else {
+ array = new List(length);
+ for (int i = 0; i < length; i++) {
+ final string = strings[i];
+ checkNull(string);
+ if (string is !String) throw new IllegalArgumentException(string);
+ array[i] = string;
+ }
}
- return result;
+ return array;
}
}

Powered by Google App Engine
This is Rietveld 408576698