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

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

Issue 1969683002: Update _charCodeApply, makeFixedStringUnmodifiable (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
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 9b07cf5f45c89260f6980dcc112c267c0975f206..30227507057f4c69d96f10ab1775d3b187f69f05 100644
--- a/tool/input_sdk/private/js_helper.dart
+++ b/tool/input_sdk/private/js_helper.dart
@@ -240,19 +240,17 @@ class Primitives {
// This is to avoid stack overflows due to very large argument arrays in
// apply(). It fixes http://dartbug.com/6919
static String _fromCharCodeApply(List<int> array) {
- String result = "";
const kMaxApply = 500;
int end = array.length;
- for (var i = 0; i < end; i += kMaxApply) {
- var subarray;
- if (end <= kMaxApply) {
- subarray = array;
- } else {
- subarray = JS('JSExtendableArray', r'#.slice(#, #)', array,
- i, i + kMaxApply < end ? i + kMaxApply : end);
- }
- result = JS('String', '# + String.fromCharCode.apply(#, #)',
- result, null, subarray);
+ if (end <= kMaxApply) {
+ return JS('String', r'String.fromCharCode.apply(null, #)', array);
+ }
+ String result = '';
+ for (int i = 0; i < end; i += kMaxApply) {
+ int chunkEnd = (i + kMaxApply < end) ? i + kMaxApply : end;
+ result = JS('String',
+ r'# + String.fromCharCode.apply(null, #.slice(#, #))',
+ result, array, i, chunkEnd);
}
return result;
}

Powered by Google App Engine
This is Rietveld 408576698