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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_string.dart

Issue 11411092: Revert "Add some support for the code-point code-unit distinction." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/js_string.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
index 86f322b21f4439aeb5ffd99b18a78e36711f3018..9c438ac47757261fcdbe3d0244099834ae49b2e6 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
@@ -13,7 +13,7 @@ part of _interceptors;
class JSString implements String {
const JSString();
- int codeUnitAt(index) {
+ int charCodeAt(index) {
if (index is !num) throw new ArgumentError(index);
if (index < 0) throw new RangeError.value(index);
if (index >= length) throw new RangeError.value(index);
@@ -86,32 +86,10 @@ class JSString implements String {
return JS('String', r'#.trim()', this);
}
- int charCodeAt(int index) {
- if (index is !num) throw new ArgumentError(index);
- if (index < 0) throw new RangeError.value(index);
- if (index >= length) throw new RangeError.value(index);
- int codeUnit = JS('int', r'#.charCodeAt(#)', this, index);
- if (codeUnit < 0xd800 || codeUnit >= 0xe000) return codeUnit;
- if (index + 1 == length) return codeUnit;
- int codeUnit2 = JS('int', r'#.charCodeAt(#)', this, index + 1);
- return 0x10000 + ((codeUnit & 0x3ff) << 10) + (codeUnit2 & 0x3ff);
- }
-
- List<int> get codeUnits {
+ List<int> get charCodes {
List<int> result = new List<int>(length);
for (int i = 0; i < length; i++) {
- result[i] = JS('int', '#.charCodeAt(#)', this, i);
- }
- return result;
- }
-
- List<int> get charCodes {
- int len = length;
- List<int> result = <int>[];
- for (int i = 0, j = 0; i < len; i++, j++) {
- int code = charCodeAt(i);
- if (code >= 0x10000) i++;
- result.add(code);
+ result[i] = charCodeAt(i);
}
return result;
}

Powered by Google App Engine
This is Rietveld 408576698