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 29 matching lines...) Expand all Loading... |
40 /* patch */ const factory String.fromEnvironment(String name, | 40 /* patch */ const factory String.fromEnvironment(String name, |
41 {String defaultValue}) | 41 {String defaultValue}) |
42 native "String_fromEnvironment"; | 42 native "String_fromEnvironment"; |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 /** | 46 /** |
47 * [_StringBase] contains common methods used by concrete String | 47 * [_StringBase] contains common methods used by concrete String |
48 * implementations, e.g., _OneByteString. | 48 * implementations, e.g., _OneByteString. |
49 */ | 49 */ |
50 class _StringBase { | 50 abstract class _StringBase { |
51 // Constants used by replaceAll encoding of string slices between matches. | 51 // Constants used by replaceAll encoding of string slices between matches. |
52 // A string slice (start+length) is encoded in a single Smi to save memory | 52 // A string slice (start+length) is encoded in a single Smi to save memory |
53 // overhead in the common case. | 53 // overhead in the common case. |
54 // We use fewer bits for length (11 bits) than for the start index (19+ bits). | 54 // We use fewer bits for length (11 bits) than for the start index (19+ bits). |
55 // For long strings, it's possible to have many large indices, | 55 // For long strings, it's possible to have many large indices, |
56 // but it's unlikely to have many long lengths since slices don't overlap. | 56 // but it's unlikely to have many long lengths since slices don't overlap. |
57 // If there are few matches in a long string, then there are few long slices, | 57 // If there are few matches in a long string, then there are few long slices, |
58 // and if there are many matches, there'll likely be many short slices. | 58 // and if there are many matches, there'll likely be many short slices. |
59 // | 59 // |
60 // Encoding is: 0((start << _lengthBits) | length) | 60 // Encoding is: 0((start << _lengthBits) | length) |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 int end = index + _pattern.length; | 1351 int end = index + _pattern.length; |
1352 _current = new _StringMatch(index, _input, _pattern); | 1352 _current = new _StringMatch(index, _input, _pattern); |
1353 // Empty match, don't start at same location again. | 1353 // Empty match, don't start at same location again. |
1354 if (end == _index) end++; | 1354 if (end == _index) end++; |
1355 _index = end; | 1355 _index = end; |
1356 return true; | 1356 return true; |
1357 } | 1357 } |
1358 | 1358 |
1359 Match get current => _current; | 1359 Match get current => _current; |
1360 } | 1360 } |
OLD | NEW |