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

Side by Side Diff: runtime/lib/string_base.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Remove CollectionUtils.mappedBy in Swarm. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * [_StringBase] contains common methods used by concrete String 6 * [_StringBase] contains common methods used by concrete String
7 * implementations, e.g., _OneByteString. 7 * implementations, e.g., _OneByteString.
8 */ 8 */
9 class _StringBase { 9 class _StringBase {
10 10
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 result[i] = this.charCodeAt(i); 325 result[i] = this.charCodeAt(i);
326 } 326 }
327 return result; 327 return result;
328 } 328 }
329 329
330 String toUpperCase() native "String_toUpperCase"; 330 String toUpperCase() native "String_toUpperCase";
331 331
332 String toLowerCase() native "String_toLowerCase"; 332 String toLowerCase() native "String_toLowerCase";
333 333
334 // Implementations of Strings methods follow below. 334 // Implementations of Strings methods follow below.
335 static String join(List<String> strings, String separator) { 335 static String join(Iterable<String> strings, String separator) {
336 final int length = strings.length; 336 bool first = true;
337 if (length == 0) { 337 List<String> stringsList = <String>[];
338 return ""; 338 for (String string in strings) {
339 } 339 if (first) {
340 first = false;
341 } else {
342 stringsList.add(separator);
343 }
340 344
341 List stringsList = strings; 345 if (string is! String) throw new ArgumentError(string);
342 if (separator.length != 0) { 346 stringsList.add(string);
343 stringsList = new List(2 * length - 1);
344 stringsList[0] = strings[0];
345 int j = 1;
346 for (int i = 1; i < length; i++) {
347 stringsList[j++] = separator;
348 stringsList[j++] = strings[i];
349 }
350 } 347 }
351 return concatAll(stringsList); 348 return concatAll(stringsList);
352 } 349 }
353 350
354 static String concatAll(List<String> strings) { 351 static String concatAll(Iterable<String> strings) {
355 _ObjectArray stringsArray; 352 _ObjectArray stringsArray;
356 if (strings is _ObjectArray) { 353 if (strings is _ObjectArray) {
357 stringsArray = strings; 354 stringsArray = strings;
355 for (int i = 0; i < strings.length; i++) {
356 if (strings[i] is! String) throw new ArgumentError(strings[i]);
357 }
358 } else { 358 } else {
359 int len = strings.length; 359 int len = strings.length;
360 stringsArray = new _ObjectArray(len); 360 stringsArray = new _ObjectArray(len);
361 for (int i = 0; i < len; i++) { 361 int i = 0;
362 stringsArray[i] = strings[i]; 362 for (String string in strings) {
363 if (string is! String) throw new ArgumentError(string);
364 stringsArray[i++] = string;
363 } 365 }
364 } 366 }
365 return _concatAll(stringsArray); 367 return _concatAll(stringsArray);
366 } 368 }
367 369
368 static String _concatAll(List<String> strings) 370 static String _concatAll(List<String> strings)
369 native "Strings_concatAll"; 371 native "Strings_concatAll";
370 } 372 }
371 373
372 374
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 for (int g in groups) { 496 for (int g in groups) {
495 result.add(group(g)); 497 result.add(group(g));
496 } 498 }
497 return result; 499 return result;
498 } 500 }
499 501
500 final int start; 502 final int start;
501 final String str; 503 final String str;
502 final String pattern; 504 final String pattern;
503 } 505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698