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

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

Issue 11348035: Move StringImplementation from coreimpl to core as _StringImpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 /** 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(List<int> charCodes) {
23 // TODO(ajohnsen): Add fast path once string_base is in core. 23 _ObjectArray objectArray;
24 int len = charCodes.length; 24 if (charCodes is _ObjectArray) {
25 var objectArray = new List(len); 25 objectArray = charCodes;
26 for (int i = 0; i < len; i++) { 26 } else {
27 objectArray[i] = charCodes[i]; 27 int len = charCodes.length;
28 objectArray = new _ObjectArray(len);
29 for (int i = 0; i < len; i++) {
30 objectArray[i] = charCodes[i];
31 }
28 } 32 }
29 return _createFromCodePoints(objectArray); 33 return _createFromCodePoints(objectArray);
30 } 34 }
31 35
32 static String _createFromCodePoints(List<int> codePoints) 36 static String _createFromCodePoints(List<int> codePoints)
33 native "StringBase_createFromCodePoints"; 37 native "StringBase_createFromCodePoints";
34 38
35 String operator [](int index) native "String_charAt"; 39 String operator [](int index) native "String_charAt";
36 40
37 int charCodeAt(int index) native "String_charCodeAt"; 41 int charCodeAt(int index) native "String_charCodeAt";
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 int j = 1; 329 int j = 1;
326 for (int i = 1; i < length; i++) { 330 for (int i = 1; i < length; i++) {
327 stringsList[j++] = separator; 331 stringsList[j++] = separator;
328 stringsList[j++] = strings[i]; 332 stringsList[j++] = strings[i];
329 } 333 }
330 } 334 }
331 return concatAll(stringsList); 335 return concatAll(stringsList);
332 } 336 }
333 337
334 static String concatAll(List<String> strings) { 338 static String concatAll(List<String> strings) {
335 // TODO(ajohnsen): Add fast path once string_base is in core. 339 _ObjectArray stringsArray;
336 int len = strings.length; 340 if (strings is _ObjectArray) {
337 var stringsArray = new List(len); 341 stringsArray = strings;
338 for (int i = 0; i < len; i++) { 342 } else {
339 stringsArray[i] = strings[i]; 343 int len = strings.length;
344 stringsArray = new _ObjectArray(len);
345 for (int i = 0; i < len; i++) {
346 stringsArray[i] = strings[i];
347 }
340 } 348 }
341 return _concatAll(stringsArray); 349 return _concatAll(stringsArray);
342 } 350 }
343 351
344 static String _concatAll(List<String> strings) 352 static String _concatAll(List<String> strings)
345 native "Strings_concatAll"; 353 native "Strings_concatAll";
346 } 354 }
347 355
348 356
349 class _OneByteString extends _StringBase implements String { 357 class _OneByteString extends _StringBase implements String {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 for (int g in groups) { 478 for (int g in groups) {
471 result.add(group(g)); 479 result.add(group(g));
472 } 480 }
473 return result; 481 return result;
474 } 482 }
475 483
476 final int start; 484 final int start;
477 final String str; 485 final String str;
478 final String pattern; 486 final String pattern;
479 } 487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698