Chromium Code Reviews| Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| index 313d2cb43c257ae90db0aa31a2a5eb0597f33a01..eb277b0efb5537dedd046953b5ff386fa7a6f3a2 100644 |
| --- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| @@ -60,6 +60,8 @@ import 'dart:_interceptors'; |
| import 'dart:_internal' as _symbol_dev; |
| import 'dart:_internal' show MappedIterable; |
| +import 'dart:_native_typed_data'; |
| + |
| import 'dart:_js_names' show |
| extractKeys, |
| mangledNames, |
| @@ -764,19 +766,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; |
|
Lasse Reichstein Nielsen
2015/01/21 09:36:38
Parentheses around ?-condition if it's non-trivial
sra1
2015/01/21 20:27:05
Done.
|
| + result = JS('String', |
| + r'# + String.fromCharCode.apply(null, #.slice(#, #))', |
| + result, array, i, chunkEnd); |
| } |
| return result; |
| } |
| @@ -806,6 +806,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(charCode) { |
| if (0 <= charCode) { |
| if (charCode <= 0xffff) { |