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

Unified Diff: sdk/lib/internal/internal.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: Move CodeUnits.cid to VM-only patch file. It makes no sense for dart2js Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/internal/internal.dart
diff --git a/sdk/lib/internal/internal.dart b/sdk/lib/internal/internal.dart
index 10b961312a021eacd49e1f84b2f652af6eb02821..854959c6596c8dd97c4a05b5e86329cefede19aa 100644
--- a/sdk/lib/internal/internal.dart
+++ b/sdk/lib/internal/internal.dart
@@ -45,3 +45,18 @@ const POWERS_OF_TEN = const [
1000000000000000000000.0,
10000000000000000000000.0,
];
+
+/**
+ * An [Iterable] of the UTF-16 code units of a [String] in index order.
+ */
+class CodeUnits extends UnmodifiableListBase<int> {
+ /** The string that this is the code units of. */
+ String _string;
Vyacheslav Egorov (Google) 2015/01/29 13:04:54 can this be final?
Lasse Reichstein Nielsen 2015/01/29 13:13:28 Absolutely.
+
+ CodeUnits(this._string);
+
+ int get length => _string.length;
+ int operator[](int i) => _string.codeUnitAt(i);
+
+ static String stringOf(CodeUnits u) => u._string;
+}

Powered by Google App Engine
This is Rietveld 408576698