| Index: runtime/lib/string_patch.dart
|
| diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
|
| index 9a454b114da22988e9e3ccbb692b605011f8ea72..05888b1ace5088500f1619e79ca0a04013902ba4 100644
|
| --- a/runtime/lib/string_patch.dart
|
| +++ b/runtime/lib/string_patch.dart
|
| @@ -683,6 +683,24 @@ class _OneByteString extends _StringBase implements String {
|
| return super.split(pattern);
|
| }
|
|
|
| + int _oneCodeUnitAt(int index) => _codeUnitsAt(index, 1);
|
| + int _twoCodeUnitsAt(int index) => _codeUnitsAt(index, 2);
|
| + int _fourCodeUnitsAt(int index) => _codeUnitsAt(index, 4);
|
| +
|
| + // Loads up to 4 code units into a single integer.
|
| + int _codeUnitsAt(int index, int count) {
|
| + assert(index >= 0);
|
| + assert(index + count - 1 < this.length);
|
| + assert(0 < count && count <= 4);
|
| +
|
| + int codeUnits = 0;
|
| + for (int i = 0; i < count; i++) {
|
| + codeUnits |= this.codeUnitAt(index + i) << (i * 8);
|
| + }
|
| +
|
| + return codeUnits;
|
| + }
|
| +
|
| // All element of 'strings' must be OneByteStrings.
|
| static _concatAll(List<String> strings, int totalLength) {
|
| // TODO(srdjan): Improve code below and raise or eliminate the limit.
|
| @@ -946,6 +964,23 @@ class _TwoByteString extends _StringBase implements String {
|
| bool operator ==(Object other) {
|
| return super == other;
|
| }
|
| +
|
| + int _oneCodeUnitAt(int index) => _codeUnitsAt(index, 1);
|
| + int _twoCodeUnitsAt(int index) => _codeUnitsAt(index, 2);
|
| +
|
| + // Loads up to 2 code units into a single integer.
|
| + int _codeUnitsAt(int index, int count) {
|
| + assert(index >= 0);
|
| + assert(index + count - 1 < this.length);
|
| + assert(0 < count && count <= 2);
|
| +
|
| + int codeUnits = 0;
|
| + for (int i = 0; i < count; i++) {
|
| + codeUnits |= this.codeUnitAt(index + i) << (i * 16);
|
| + }
|
| +
|
| + return codeUnits;
|
| + }
|
| }
|
|
|
|
|
|
|