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

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

Issue 2467113003: Make EfficientLength extend Iterable. (Closed)
Patch Set: Reverted, prepare to reland. Make new test not break web-testing framework. Created 4 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
« no previous file with comments | « runtime/lib/immutable_map.dart ('k') | runtime/vm/debugger_api_impl_test.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 int code = charCodes[i]; 148 int code = charCodes[i];
149 if (code is! _Smi) throw new ArgumentError(charCodes); 149 if (code is! _Smi) throw new ArgumentError(charCodes);
150 bits |= code; 150 bits |= code;
151 } 151 }
152 return bits; 152 return bits;
153 } 153 }
154 154
155 static String _createStringFromIterable(Iterable<int> charCodes, 155 static String _createStringFromIterable(Iterable<int> charCodes,
156 int start, int end) { 156 int start, int end) {
157 // Treat charCodes as Iterable. 157 // Treat charCodes as Iterable.
158 if (charCodes is EfficientLength) { 158 if (charCodes is EfficientLengthIterable) {
159 int length = charCodes.length; 159 int length = charCodes.length;
160 end = RangeError.checkValidRange(start, end, length); 160 end = RangeError.checkValidRange(start, end, length);
161 List charCodeList = new List.from(charCodes.take(end).skip(start), 161 List charCodeList = new List.from(charCodes.take(end).skip(start),
162 growable: false); 162 growable: false);
163 return createFromCharCodes(charCodeList, 0, charCodeList.length, null); 163 return createFromCharCodes(charCodeList, 0, charCodeList.length, null);
164 } 164 }
165 // Don't know length of iterable, so iterate and see if all the values 165 // Don't know length of iterable, so iterate and see if all the values
166 // are there. 166 // are there.
167 if (start < 0) throw new RangeError.range(start, 0, charCodes.length); 167 if (start < 0) throw new RangeError.range(start, 0, charCodes.length);
168 var it = charCodes.iterator; 168 var it = charCodes.iterator;
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 int end = index + _pattern.length; 1357 int end = index + _pattern.length;
1358 _current = new _StringMatch(index, _input, _pattern); 1358 _current = new _StringMatch(index, _input, _pattern);
1359 // Empty match, don't start at same location again. 1359 // Empty match, don't start at same location again.
1360 if (end == _index) end++; 1360 if (end == _index) end++;
1361 _index = end; 1361 _index = end;
1362 return true; 1362 return true;
1363 } 1363 }
1364 1364
1365 Match get current => _current; 1365 Match get current => _current;
1366 } 1366 }
OLDNEW
« no previous file with comments | « runtime/lib/immutable_map.dart ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698