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

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

Issue 596763002: Optimize int.parse with a radix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert mis-merged patch that got into this CL by mistake. Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/core_patch.dart » ('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 patch class String { 5 patch class String {
6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes, 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes,
7 [int start = 0, int end]) { 7 [int start = 0, int end]) {
8 return _StringBase.createFromCharCodes(charCodes, start, end); 8 return _StringBase.createFromCharCodes(charCodes, start, end);
9 } 9 }
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 int get hashCode native "String_getHashCode"; 51 int get hashCode native "String_getHashCode";
52 52
53 /** 53 /**
54 * Create the most efficient string representation for specified 54 * Create the most efficient string representation for specified
55 * [codePoints]. 55 * [codePoints].
56 */ 56 */
57 static String createFromCharCodes(Iterable<int> charCodes, 57 static String createFromCharCodes(Iterable<int> charCodes,
58 int start, int end) { 58 int start, int end) {
59 if (charCodes == null) throw new ArgumentError(charCodes); 59 if (charCodes == null) throw new ArgumentError(charCodes);
60 if (start < 0) throw new RangeError.value(start);
60 // TODO(srdjan): Also skip copying of wide typed arrays. 61 // TODO(srdjan): Also skip copying of wide typed arrays.
61 final ccid = ClassID.getID(charCodes); 62 final ccid = ClassID.getID(charCodes);
62 bool isOneByteString = false; 63 bool isOneByteString = false;
63 if ((ccid != ClassID.cidArray) && 64 if ((ccid != ClassID.cidArray) &&
64 (ccid != ClassID.cidGrowableObjectArray) && 65 (ccid != ClassID.cidGrowableObjectArray) &&
65 (ccid != ClassID.cidImmutableArray)) { 66 (ccid != ClassID.cidImmutableArray)) {
66 if ((charCodes is Uint8List) || (charCodes is Int8List)) { 67 if ((charCodes is Uint8List) || (charCodes is Int8List)) {
67 isOneByteString = true; 68 isOneByteString = true;
68 } else { 69 } else {
69 charCodes = new List.from(charCodes, growable: false); 70 charCodes = new List.from(charCodes, growable: false);
70 } 71 }
71 } 72 }
72 int codeCount = charCodes.length; 73 if ((end == null) || (end > charCodes.length)) {
73 if (start < 0 || start > codeCount) { 74 end = charCodes.length;
74 throw new RangeError.range(start, 0, codeCount);
75 } 75 }
76 if (end == null) { 76 if (end <= start) return "";
77 end = codeCount;
78 } else if (end < start || end > codeCount) {
79 throw new RangeError.range(end, start, codeCount);
80 }
81 final len = end - start; 77 final len = end - start;
82 if (!isOneByteString) { 78 if (!isOneByteString) {
83 for (int i = start; i < end; i++) { 79 for (int i = start; i < end; i++) {
84 int e = charCodes[i]; 80 int e = charCodes[i];
85 if (e is! _Smi) throw new ArgumentError(e); 81 if (e is! _Smi) throw new ArgumentError(e);
86 // Is e Latin1? 82 // Is e Latin1?
87 if ((e < 0) || (e > 0xFF)) { 83 if ((e < 0) || (e > 0xFF)) {
88 return _createFromCodePoints(charCodes, start, end); 84 return _createFromCodePoints(charCodes, start, end);
89 } 85 }
90 } 86 }
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 class _CodeUnits extends Object with ListMixin<int>, 1031 class _CodeUnits extends Object with ListMixin<int>,
1036 UnmodifiableListMixin<int> { 1032 UnmodifiableListMixin<int> {
1037 /** The string that this is the code units of. */ 1033 /** The string that this is the code units of. */
1038 String _string; 1034 String _string;
1039 1035
1040 _CodeUnits(this._string); 1036 _CodeUnits(this._string);
1041 1037
1042 int get length => _string.length; 1038 int get length => _string.length;
1043 int operator[](int i) => _string.codeUnitAt(i); 1039 int operator[](int i) => _string.codeUnitAt(i);
1044 } 1040 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698