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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 212423003: Optimize String.fromCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Shortcut List creation. Created 6 years, 9 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
« no previous file with comments | « sdk/lib/_internal/lib/core_patch.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index ed7f3c92204e445ce0a97dde819dc211bcb6cfad..6a14662946200f05d9e44f94b9532e1bd9c6cd08 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -760,6 +760,21 @@ class Primitives {
return _fromCharCodeApply(charCodes);
}
+ static String stringFromCharCode(charCode) {
+ if (0 <= charCode) {
+ if (charCode <= 0xffff) {
+ return JS('String', 'String.fromCharCode(#)', charCode);
+ }
+ if (charCode <= 0x10ffff) {
+ var bits = charCode - 0x10000;
+ var low = 0xDC00 | (bits & 0x3ff);
+ var high = 0xD800 | (bits >> 10);
+ return JS('String', 'String.fromCharCode(#, #)', high, low);
+ }
+ }
+ throw new RangeError.range(charCode, 0, 0x10ffff);
+ }
+
static String stringConcatUnchecked(String string1, String string2) {
return JS('String', r'# + #', string1, string2);
}
« no previous file with comments | « sdk/lib/_internal/lib/core_patch.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698