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

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

Issue 11414273: Added native to split OneByteString with a char code as pattern. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « runtime/lib/string.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 /** 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
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid 382 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
383 // whitespaces for one byte strings. 383 // whitespaces for one byte strings.
384 bool _isWhitespace(int codePoint) { 384 bool _isWhitespace(int codePoint) {
385 return 385 return
386 (codePoint == 32) || // Space. 386 (codePoint == 32) || // Space.
387 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 387 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
388 } 388 }
389 389
390 String _substringUncheckedNative(int startIndex, int endIndex) 390 String _substringUncheckedNative(int startIndex, int endIndex)
391 native "OneByteString_substringUnchecked"; 391 native "OneByteString_substringUnchecked";
392
393 List<String> _splitWithCharCode(int charCode)
394 native "OneByteString_splitWithCharCode";
395
396 List<String> split(Pattern pattern) {
397 if ((pattern is _OneByteString) && (pattern.length == 1)) {
398 return _splitWithCharCode(pattern.charCodeAt(0));
399 }
400 return super.split(pattern);
401 }
392 } 402 }
393 403
394 404
395 class _TwoByteString extends _StringBase implements String { 405 class _TwoByteString extends _StringBase implements String {
396 factory _TwoByteString._uninstantiable() { 406 factory _TwoByteString._uninstantiable() {
397 throw new UnsupportedError( 407 throw new UnsupportedError(
398 "_TwoByteString can only be allocated by the VM"); 408 "_TwoByteString can only be allocated by the VM");
399 } 409 }
400 410
401 // Checks for one-byte whitespaces only. 411 // Checks for one-byte whitespaces only.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 for (int g in groups) { 508 for (int g in groups) {
499 result.add(group(g)); 509 result.add(group(g));
500 } 510 }
501 return result; 511 return result;
502 } 512 }
503 513
504 final int start; 514 final int start;
505 final String str; 515 final String str;
506 final String pattern; 516 final String pattern;
507 } 517 }
OLDNEW
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698