diff --git a/lib/src/duration.dart b/lib/src/duration.dart index 9e256600..6e8ec0c8 100644 --- a/lib/src/duration.dart +++ b/lib/src/duration.dart @@ -38,8 +38,10 @@ abstract class ITime { static final /*BigInt*/ int maxNanoseconds = (maxDays + 1 /*BigInteger.One*/) * TimeConstants.nanosecondsPerDay - 1; // 285420 years worth -- we are good for anything; + // todo: should this be specific to the Platform? + // todo: why was minMillis == -9007199254740993, which is Platform.intMinValueJS-1; static const int maxMillis = Platform.intMaxValueJS; - static const int minMillis = -9007199254740993; // Utility.intMinValueJS; // was -maxMillis; very shortly was ~maxMillis (which I guess doesn't work well in JS) + static const int minMillis = Platform.intMinValueJS; // -9007199254740993; // Utility.intMinValueJS; // was -maxMillis; very shortly was ~maxMillis (which I guess doesn't work well in JS) static bool isInt64Representable(Time span) => span._isInt64Representable; static Time plusSmallNanoseconds(Time span, int nanoseconds) => span._plusSmallNanoseconds(nanoseconds); diff --git a/lib/src/text/value_cursor.dart b/lib/src/text/value_cursor.dart index 712e2e0a..ea75284c 100644 --- a/lib/src/text/value_cursor.dart +++ b/lib/src/text/value_cursor.dart @@ -126,7 +126,7 @@ class ValueCursor extends TextCursor { } int count = 0; int digit; - while (result < 922337203685477580 && (digit = _getDigit()) != -1) { + while (result < Platform.valueCursorPrediction && (digit = _getDigit()) != -1) { result = result * 10 + digit; count++; if (!moveNext()) { @@ -139,8 +139,8 @@ class ValueCursor extends TextCursor { return IParseResult.missingNumber(this); } - if (result >= 922337203685477580 && (digit = _getDigit()) != -1) { - if (result > 922337203685477580) { + if (result >= Platform.valueCursorPrediction && (digit = _getDigit()) != -1) { + if (result > Platform.valueCursorPrediction) { return _buildNumberOutOfRangeResult(startIndex, tType); } if (negative && digit == 8) { diff --git a/lib/src/utility/utilities.dart b/lib/src/utility/utilities.dart index 6890589d..9bc99882 100644 --- a/lib/src/utility/utilities.dart +++ b/lib/src/utility/utilities.dart @@ -38,12 +38,16 @@ abstract class Platform { static bool get isWeb => _isWeb ?? dirtyCheck() ?? _isWeb; static bool get isVM => _isVM ?? dirtyCheck() ?? _isVM; - static const intMaxValueJS = 9007199254740992; // math.pow(2, 53); - static const intMinValueJS = -9007199254740992; // -math.pow(2, 53); appears to be the same (not 1 more, not 1 less) - static const int32MinValue = -2147483648; - static const int32MaxValue = 2147483647; - static const int64MinValue = -9223372036854775808; - static const int64MaxValue = 9223372036854775807; + static const int intMaxValueJS = 9007199254740992; // math.pow(2, 53); + static const int intMinValueJS = -9007199254740992; // -math.pow(2, 53); appears to be the same (not 1 more, not 1 less) + static const int int32MinValue = -2147483648; + static const int int32MaxValue = 2147483647; + + // representable in JS and VM: +\- 9223372036854775000 (but, constants in JS must be bounded by intMinValueJS and intMaxValueJS) + // Fix for: https://github.com/dart-lang/sdk/issues/33282 <-- bizarre + static const int valueCursorPrediction = 13860*66546695792603; // vm: 922337203685477580; js: 922337203685477600 + static const int int64MinValue = 2147483648 * 2147483648 * -2; // vm: -9223372036854775808; js: -9223372036854776000 + static const int int64MaxValue = 2147483648 * 2147483648 - 1 + 2147483648 * 2147483648; // vm: 9223372036854775807; js: 9223372036854776000 static int _intMaxValue = isVM ? _intMaxValue = int64MaxValue : _intMaxValue = intMaxValueJS; static int _intMinValue = isVM ? _intMinValue = int64MinValue : _intMinValue = intMinValueJS; @@ -61,15 +65,6 @@ abstract class IDateTimeZoneWriter { // } -// todo: all of these may affect performance - -// todo: only use this for porting... remove all of these later -@deprecated -class OutBox { - T value; - OutBox(this.value); -} - // https://en.wikipedia.org/wiki/Modulo_operation // we should only use this where 'x' can be negative int arithmeticMod(num x, int y) {