Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: runtime/lib/string_patch.dart

Issue 1961393002: VM: Optimized code for all of [External]{One|Two}ByteString::codeUnitAt. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/aot_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // TODO(lrn): Create string without scanning charCodes again - all values 223 // TODO(lrn): Create string without scanning charCodes again - all values
224 // in the [start..end] range are uint16 values. 224 // in the [start..end] range are uint16 values.
225 return _createFromCodePoints(charCodes, start, end); 225 return _createFromCodePoints(charCodes, start, end);
226 } 226 }
227 227
228 static String _createFromCodePoints(List<int> codePoints, int start, int end) 228 static String _createFromCodePoints(List<int> codePoints, int start, int end)
229 native "StringBase_createFromCodePoints"; 229 native "StringBase_createFromCodePoints";
230 230
231 String operator [](int index) native "String_charAt"; 231 String operator [](int index) native "String_charAt";
232 232
233 int codeUnitAt(int index) native "String_codeUnitAt"; 233 int codeUnitAt(int index); // Implemented in the subclasses.
234 234
235 int get length native "String_getLength"; 235 int get length native "String_getLength";
236 236
237 bool get isEmpty { 237 bool get isEmpty {
238 return this.length == 0; 238 return this.length == 0;
239 } 239 }
240 240
241 bool get isNotEmpty => !isEmpty; 241 bool get isNotEmpty => !isEmpty;
242 242
243 String operator +(String other) native "String_concat"; 243 String operator +(String other) native "String_concat";
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 930
931 class _OneByteString extends _StringBase implements String { 931 class _OneByteString extends _StringBase implements String {
932 932
933 factory _OneByteString._uninstantiable() { 933 factory _OneByteString._uninstantiable() {
934 throw new UnsupportedError( 934 throw new UnsupportedError(
935 "_OneByteString can only be allocated by the VM"); 935 "_OneByteString can only be allocated by the VM");
936 } 936 }
937 937
938 int get hashCode native "String_getHashCode"; 938 int get hashCode native "String_getHashCode";
939 939
940 int codeUnitAt(int index) native "String_codeUnitAt";
941
940 bool _isWhitespace(int codeUnit) { 942 bool _isWhitespace(int codeUnit) {
941 return _StringBase._isOneByteWhitespace(codeUnit); 943 return _StringBase._isOneByteWhitespace(codeUnit);
942 } 944 }
943 945
944 bool operator ==(Object other) { 946 bool operator ==(Object other) {
945 return super == other; 947 return super == other;
946 } 948 }
947 949
948 String _substringUncheckedNative(int startIndex, int endIndex) 950 String _substringUncheckedNative(int startIndex, int endIndex)
949 native "OneByteString_substringUnchecked"; 951 native "OneByteString_substringUnchecked";
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 "_TwoByteString can only be allocated by the VM"); 1235 "_TwoByteString can only be allocated by the VM");
1234 } 1236 }
1235 1237
1236 static String _allocateFromTwoByteList(List list, int start, int end) 1238 static String _allocateFromTwoByteList(List list, int start, int end)
1237 native "TwoByteString_allocateFromTwoByteList"; 1239 native "TwoByteString_allocateFromTwoByteList";
1238 1240
1239 bool _isWhitespace(int codeUnit) { 1241 bool _isWhitespace(int codeUnit) {
1240 return _StringBase._isTwoByteWhitespace(codeUnit); 1242 return _StringBase._isTwoByteWhitespace(codeUnit);
1241 } 1243 }
1242 1244
1245 int codeUnitAt(int index) native "String_codeUnitAt";
1246
1243 bool operator ==(Object other) { 1247 bool operator ==(Object other) {
1244 return super == other; 1248 return super == other;
1245 } 1249 }
1246 } 1250 }
1247 1251
1248 1252
1249 class _ExternalOneByteString extends _StringBase implements String { 1253 class _ExternalOneByteString extends _StringBase implements String {
1250 factory _ExternalOneByteString._uninstantiable() { 1254 factory _ExternalOneByteString._uninstantiable() {
1251 throw new UnsupportedError( 1255 throw new UnsupportedError(
1252 "_ExternalOneByteString can only be allocated by the VM"); 1256 "_ExternalOneByteString can only be allocated by the VM");
1253 } 1257 }
1254 1258
1255 bool _isWhitespace(int codeUnit) { 1259 bool _isWhitespace(int codeUnit) {
1256 return _StringBase._isOneByteWhitespace(codeUnit); 1260 return _StringBase._isOneByteWhitespace(codeUnit);
1257 } 1261 }
1258 1262
1263 int codeUnitAt(int index) native "String_codeUnitAt";
1264
1259 bool operator ==(Object other) { 1265 bool operator ==(Object other) {
1260 return super == other; 1266 return super == other;
1261 } 1267 }
1262 1268
1263 static int _getCid() native "ExternalOneByteString_getCid"; 1269 static int _getCid() native "ExternalOneByteString_getCid";
1264 } 1270 }
1265 1271
1266 1272
1267 class _ExternalTwoByteString extends _StringBase implements String { 1273 class _ExternalTwoByteString extends _StringBase implements String {
1268 factory _ExternalTwoByteString._uninstantiable() { 1274 factory _ExternalTwoByteString._uninstantiable() {
1269 throw new UnsupportedError( 1275 throw new UnsupportedError(
1270 "_ExternalTwoByteString can only be allocated by the VM"); 1276 "_ExternalTwoByteString can only be allocated by the VM");
1271 } 1277 }
1272 1278
1273 bool _isWhitespace(int codeUnit) { 1279 bool _isWhitespace(int codeUnit) {
1274 return _StringBase._isTwoByteWhitespace(codeUnit); 1280 return _StringBase._isTwoByteWhitespace(codeUnit);
1275 } 1281 }
1276 1282
1283 int codeUnitAt(int index) native "String_codeUnitAt";
1284
1277 bool operator ==(Object other) { 1285 bool operator ==(Object other) {
1278 return super == other; 1286 return super == other;
1279 } 1287 }
1280 } 1288 }
1281 1289
1282 1290
1283 class _StringMatch implements Match { 1291 class _StringMatch implements Match {
1284 const _StringMatch(int this.start, 1292 const _StringMatch(int this.start,
1285 String this.input, 1293 String this.input,
1286 String this.pattern); 1294 String this.pattern);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 int end = index + _pattern.length; 1359 int end = index + _pattern.length;
1352 _current = new _StringMatch(index, _input, _pattern); 1360 _current = new _StringMatch(index, _input, _pattern);
1353 // Empty match, don't start at same location again. 1361 // Empty match, don't start at same location again.
1354 if (end == _index) end++; 1362 if (end == _index) end++;
1355 _index = end; 1363 _index = end;
1356 return true; 1364 return true;
1357 } 1365 }
1358 1366
1359 Match get current => _current; 1367 Match get current => _current;
1360 } 1368 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/aot_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698