| 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 const int _maxAscii = 0x7f; | 5 const int _maxAscii = 0x7f; |
| 6 const int _maxLatin1 = 0xff; | 6 const int _maxLatin1 = 0xff; |
| 7 const int _maxUtf16 = 0xffff; | 7 const int _maxUtf16 = 0xffff; |
| 8 const int _maxUnicode = 0x10ffff; | 8 const int _maxUnicode = 0x10ffff; |
| 9 | 9 |
| 10 @patch class String { | 10 @patch class String { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 static String _createOneByteString(List<int> charCodes, int start, int len) { | 211 static String _createOneByteString(List<int> charCodes, int start, int len) { |
| 212 // It's always faster to do this in Dart than to call into the runtime. | 212 // It's always faster to do this in Dart than to call into the runtime. |
| 213 var s = _OneByteString._allocate(len); | 213 var s = _OneByteString._allocate(len); |
| 214 for (int i = 0; i < len; i++) { | 214 for (int i = 0; i < len; i++) { |
| 215 s._setAt(i, charCodes[start + i]); | 215 s._setAt(i, charCodes[start + i]); |
| 216 } | 216 } |
| 217 return s; | 217 return s; |
| 218 } | 218 } |
| 219 | 219 |
| 220 static String _createTwoByteString(List<int> charCodes, int start, int len) { | |
| 221 // TODO(lrn): Create string without scanning charCodes again - all values | |
| 222 // in the [start..end] range are uint16 values. | |
| 223 return _createFromCodePoints(charCodes, start, end); | |
| 224 } | |
| 225 | |
| 226 static String _createFromCodePoints(List<int> codePoints, int start, int end) | 220 static String _createFromCodePoints(List<int> codePoints, int start, int end) |
| 227 native "StringBase_createFromCodePoints"; | 221 native "StringBase_createFromCodePoints"; |
| 228 | 222 |
| 229 String operator [](int index) native "String_charAt"; | 223 String operator [](int index) native "String_charAt"; |
| 230 | 224 |
| 231 int codeUnitAt(int index); // Implemented in the subclasses. | 225 int codeUnitAt(int index); // Implemented in the subclasses. |
| 232 | 226 |
| 233 int get length native "String_getLength"; | 227 int get length native "String_getLength"; |
| 234 | 228 |
| 235 bool get isEmpty { | 229 bool get isEmpty { |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 int end = index + _pattern.length; | 1349 int end = index + _pattern.length; |
| 1356 _current = new _StringMatch(index, _input, _pattern); | 1350 _current = new _StringMatch(index, _input, _pattern); |
| 1357 // Empty match, don't start at same location again. | 1351 // Empty match, don't start at same location again. |
| 1358 if (end == _index) end++; | 1352 if (end == _index) end++; |
| 1359 _index = end; | 1353 _index = end; |
| 1360 return true; | 1354 return true; |
| 1361 } | 1355 } |
| 1362 | 1356 |
| 1363 Match get current => _current; | 1357 Match get current => _current; |
| 1364 } | 1358 } |
| OLD | NEW |