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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_string.dart

Issue 856053002: Let Uint16List.setRange detect a String.codeUnits object, and copy directly from the string. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 5 years, 10 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 | « runtime/lib/typed_data.dart ('k') | sdk/lib/internal/internal.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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [String]. The compiler recognizes this 8 * The interceptor class for [String]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (delta <= 0) return this; 352 if (delta <= 0) return this;
353 return padding * delta + this; 353 return padding * delta + this;
354 } 354 }
355 355
356 String padRight(int width, [String padding = ' ']) { 356 String padRight(int width, [String padding = ' ']) {
357 int delta = width - this.length; 357 int delta = width - this.length;
358 if (delta <= 0) return this; 358 if (delta <= 0) return this;
359 return this + padding * delta; 359 return this + padding * delta;
360 } 360 }
361 361
362 List<int> get codeUnits => new _CodeUnits(this); 362 List<int> get codeUnits => new CodeUnits(this);
363 363
364 Runes get runes => new Runes(this); 364 Runes get runes => new Runes(this);
365 365
366 int indexOf(Pattern pattern, [int start = 0]) { 366 int indexOf(Pattern pattern, [int start = 0]) {
367 checkNull(pattern); 367 checkNull(pattern);
368 if (start is! int) throw new ArgumentError(start); 368 if (start is! int) throw new ArgumentError(start);
369 if (start < 0 || start > this.length) { 369 if (start < 0 || start > this.length) {
370 throw new RangeError.range(start, 0, this.length); 370 throw new RangeError.range(start, 0, this.length);
371 } 371 }
372 if (pattern is String) { 372 if (pattern is String) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 Type get runtimeType => String; 449 Type get runtimeType => String;
450 450
451 int get length => JS('int', r'#.length', this); 451 int get length => JS('int', r'#.length', this);
452 452
453 String operator [](int index) { 453 String operator [](int index) {
454 if (index is !int) throw new ArgumentError(index); 454 if (index is !int) throw new ArgumentError(index);
455 if (index >= length || index < 0) throw new RangeError.value(index); 455 if (index >= length || index < 0) throw new RangeError.value(index);
456 return JS('String', '#[#]', this, index); 456 return JS('String', '#[#]', this, index);
457 } 457 }
458 } 458 }
459
460 /**
461 * An [Iterable] of the UTF-16 code units of a [String] in index order.
462 */
463 class _CodeUnits extends UnmodifiableListBase<int> {
464 /** The string that this is the code units of. */
465 String _string;
466
467 _CodeUnits(this._string);
468
469 int get length => _string.length;
470 int operator[](int i) => _string.codeUnitAt(i);
471 }
OLDNEW
« no previous file with comments | « runtime/lib/typed_data.dart ('k') | sdk/lib/internal/internal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698