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

Unified Diff: tool/input_sdk/private/js_helper.dart

Issue 1952223006: Update String.fromCharCodes from sdk (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 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 | « tool/input_sdk/patch/internal_patch.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/js_helper.dart
diff --git a/tool/input_sdk/private/js_helper.dart b/tool/input_sdk/private/js_helper.dart
index b558c03f20034277e6510a2e046448db04459f21..522729371a179ad77104f6622ef26adbeff5b059 100644
--- a/tool/input_sdk/private/js_helper.dart
+++ b/tool/input_sdk/private/js_helper.dart
@@ -16,6 +16,8 @@ import 'dart:_internal' show
MappedIterable,
IterableElementError;
+import 'dart:_native_typed_data';
+
part 'annotations.dart';
part 'native_helper.dart';
part 'regexp_helper.dart';
@@ -279,6 +281,24 @@ class Primitives {
return _fromCharCodeApply(charCodes);
}
+ // [start] and [end] are validated.
+ static String stringFromNativeUint8List(
+ NativeUint8List charCodes, int start, int end) {
+ const kMaxApply = 500;
+ if (end <= kMaxApply && start == 0 && end == charCodes.length) {
+ return JS('String', r'String.fromCharCode.apply(null, #)', charCodes);
+ }
+ String result = '';
+ for (int i = start; i < end; i += kMaxApply) {
+ int chunkEnd = (i + kMaxApply < end) ? i + kMaxApply : end;
+ result = JS('String',
+ r'# + String.fromCharCode.apply(null, #.subarray(#, #))',
+ result, charCodes, i, chunkEnd);
+ }
+ return result;
+ }
+
+
static String stringFromCharCode(int charCode) {
if (0 <= charCode) {
if (charCode <= 0xffff) {
« no previous file with comments | « tool/input_sdk/patch/internal_patch.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698