diff --git a/sdk/lib/_internal/wasm/lib/int_patch.dart b/sdk/lib/_internal/wasm/lib/int_patch.dart index a5f8eff204c..dd1050db209 100644 --- a/sdk/lib/_internal/wasm/lib/int_patch.dart +++ b/sdk/lib/_internal/wasm/lib/int_patch.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import "dart:_internal" show has63BitSmis, patch, unsafeCast; +import "dart:_string" show StringUncheckedOperations; import "dart:typed_data" show Int64List; @patch @@ -11,7 +12,7 @@ class int { assert(first <= last); var ix = first; var sign = 1; - var c = str.codeUnitAt(ix); + var c = str.codeUnitAtUnchecked(ix); // Check for leading '+' or '-'. if ((c == 0x2b) || (c == 0x2d)) { ix++; @@ -26,7 +27,7 @@ class int { } var result = 0; for (int i = ix; i <= last; i++) { - var c = 0x30 ^ str.codeUnitAt(i); + var c = 0x30 ^ str.codeUnitAtUnchecked(i); if (9 < c) { return null; } @@ -60,7 +61,7 @@ class int { } int start = source.firstNonWhitespace(); - int first = source.codeUnitAt(start); + int first = source.codeUnitAtUnchecked(start); int sign = 1; if (first == 0x2b /* + */ || first == 0x2d /* - */) { sign = 0x2c - first; // -1 if '-', +1 if '+'. @@ -68,7 +69,7 @@ class int { if (start == end) { return _handleFormatError(onError, source, end, radix, null); } - first = source.codeUnitAt(start); + first = source.codeUnitAtUnchecked(start); } if (radix == null) { // check for 0x prefix. @@ -76,7 +77,7 @@ class int { if (first == 0x30 /* 0 */) { index++; if (index == end) return 0; - first = source.codeUnitAt(index); + first = source.codeUnitAtUnchecked(index); if ((first | 0x20) == 0x78 /* x */) { index++; if (index == end) { @@ -196,13 +197,13 @@ class int { _Smi result = unsafeCast<_Smi>(0); if (radix <= 10) { for (int i = start; i < end; i++) { - int digit = source.codeUnitAt(i) ^ 0x30; + int digit = source.codeUnitAtUnchecked(i) ^ 0x30; if (digit >= radix) return null; result = (radix * result + digit) as _Smi; } } else { for (int i = start; i < end; i++) { - int char = source.codeUnitAt(i); + int char = source.codeUnitAtUnchecked(i); int digit = char ^ 0x30; if (digit > 9) { digit = (char | 0x20) - (0x61 - 10);