| OLD | NEW |
| 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 patch class String { | 5 patch class String { |
| 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { | 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { |
| 7 return _StringBase.createFromCharCodes(charCodes); | 7 return _StringBase.createFromCharCodes(charCodes); |
| 8 } | 8 } |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 502 |
| 503 List<int> get codeUnits => new _CodeUnits(this); | 503 List<int> get codeUnits => new _CodeUnits(this); |
| 504 | 504 |
| 505 Runes get runes => new Runes(this); | 505 Runes get runes => new Runes(this); |
| 506 | 506 |
| 507 String toUpperCase() native "String_toUpperCase"; | 507 String toUpperCase() native "String_toUpperCase"; |
| 508 | 508 |
| 509 String toLowerCase() native "String_toLowerCase"; | 509 String toLowerCase() native "String_toLowerCase"; |
| 510 | 510 |
| 511 // Concatenate ['start', 'end'[ elements of 'strings'. 'strings' must contain | 511 // Concatenate ['start', 'end'[ elements of 'strings'. 'strings' must contain |
| 512 // String elements. Optimized for OneByteStrings. | 512 // String elements. TODO(srdjan): optimize it. |
| 513 static String _concatRange(List<String> strings, int start, int end) { | 513 static String _concatRange(List<String> strings, int start, int end) { |
| 514 if ((end - start) == 1) { | 514 if ((end - start) == 1) { |
| 515 return strings[start]; | 515 return strings[start]; |
| 516 } | 516 } |
| 517 final numValues = strings.length; | |
| 518 if ((start == 0) && (end == numValues)) { | |
| 519 int totalLength = 0; | |
| 520 for (int i = 0; i < numValues; i++) { | |
| 521 String s = strings[i]; | |
| 522 if (s._cid != _OneByteString._classId) { | |
| 523 return _concatRangeNative(strings, start, end); | |
| 524 } | |
| 525 totalLength += s.length; | |
| 526 } | |
| 527 return _OneByteString._concatAll(strings, totalLength); | |
| 528 } | |
| 529 return _concatRangeNative(strings, start, end); | 517 return _concatRangeNative(strings, start, end); |
| 530 } | 518 } |
| 531 | 519 |
| 532 // Call this method if not all list elements are known to be OneByteString(s). | 520 // Call this method if not all list elements are known to be OneByteString(s). |
| 533 // 'strings' must be an _List or _GrowableList. | 521 // 'strings' must be an _List or _GrowableList. |
| 534 static String _concatRangeNative(List<String> strings, int start, int end) | 522 static String _concatRangeNative(List<String> strings, int start, int end) |
| 535 native "String_concatRange"; | 523 native "String_concatRange"; |
| 536 } | 524 } |
| 537 | 525 |
| 538 | 526 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 class _CodeUnits extends Object with ListMixin<int>, | 686 class _CodeUnits extends Object with ListMixin<int>, |
| 699 UnmodifiableListMixin<int> { | 687 UnmodifiableListMixin<int> { |
| 700 /** The string that this is the code units of. */ | 688 /** The string that this is the code units of. */ |
| 701 String _string; | 689 String _string; |
| 702 | 690 |
| 703 _CodeUnits(this._string); | 691 _CodeUnits(this._string); |
| 704 | 692 |
| 705 int get length => _string.length; | 693 int get length => _string.length; |
| 706 int operator[](int i) => _string.codeUnitAt(i); | 694 int operator[](int i) => _string.codeUnitAt(i); |
| 707 } | 695 } |
| OLD | NEW |