Chromium Code Reviews| 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 /** | 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 |
| 11 factory _StringBase._uninstantiable() { | 11 factory _StringBase._uninstantiable() { |
| 12 throw new UnsupportedError( | 12 throw new UnsupportedError( |
| 13 "_StringBase can't be instaniated"); | 13 "_StringBase can't be instaniated"); |
| 14 } | 14 } |
| 15 | 15 |
| 16 int get hashCode native "String_getHashCode"; | 16 int get hashCode native "String_getHashCode"; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Create the most efficient string representation for specified | 19 * Create the most efficient string representation for specified |
| 20 * [codePoints]. | 20 * [codePoints]. |
| 21 */ | 21 */ |
| 22 static String createFromCharCodes(List<int> charCodes) { | 22 static String createFromCharCodes(Iterable<int> charCodes) { |
| 23 _ObjectArray objectArray; | 23 if (charCodes is! _ObjectArray) { |
| 24 if (charCodes is _ObjectArray) { | 24 charCodes = new List<int>.from(charCodes, growable: false); |
|
floitsch
2013/03/05 14:14:04
assert that it is an _ObjectArray afterwards. (It'
| |
| 25 objectArray = charCodes; | |
| 26 } else { | |
| 27 int len = charCodes.length; | |
| 28 objectArray = new _ObjectArray(len); | |
| 29 for (int i = 0; i < len; i++) { | |
| 30 objectArray[i] = charCodes[i]; | |
| 31 } | |
| 32 } | 25 } |
| 33 return _createFromCodePoints(objectArray); | 26 return _createFromCodePoints(charCodes); |
| 34 } | 27 } |
| 35 | 28 |
| 36 static String _createFromCodePoints(List<int> codePoints) | 29 static String _createFromCodePoints(List<int> codePoints) |
| 37 native "StringBase_createFromCodePoints"; | 30 native "StringBase_createFromCodePoints"; |
| 38 | 31 |
| 39 String operator [](int index) native "String_charAt"; | 32 String operator [](int index) native "String_charAt"; |
| 40 | 33 |
| 41 int codeUnitAt(int index) native "String_codeUnitAt"; | 34 int codeUnitAt(int index) native "String_codeUnitAt"; |
| 42 | 35 |
| 43 int get length native "String_getLength"; | 36 int get length native "String_getLength"; |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 for (int g in groups) { | 597 for (int g in groups) { |
| 605 result.add(group(g)); | 598 result.add(group(g)); |
| 606 } | 599 } |
| 607 return result; | 600 return result; |
| 608 } | 601 } |
| 609 | 602 |
| 610 final int start; | 603 final int start; |
| 611 final String str; | 604 final String str; |
| 612 final String pattern; | 605 final String pattern; |
| 613 } | 606 } |
| OLD | NEW |