Chromium Code Reviews| Index: runtime/lib/integers.dart |
| diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart |
| index 5c9f7d8578ab5efdc13be114244f4a65180811ce..e450cda5daa75710930ead37485006d549564333 100644 |
| --- a/runtime/lib/integers.dart |
| +++ b/runtime/lib/integers.dart |
| @@ -294,11 +294,10 @@ class _Smi extends _IntegerImplementation implements int { |
| 0x39, 0x36, 0x39, 0x37, 0x39, 0x38, 0x39, 0x39 |
| ]; |
| - // Powers of 10 above 1000000 are indistinguishable. |
| + // Powers of 10 above 1000000 are indistinguishable by eye. |
| static const int _POW_10_7 = 10000000; |
| static const int _POW_10_8 = 100000000; |
| static const int _POW_10_9 = 1000000000; |
| - static const int _POW_10_10 = 10000000000; |
| // Find the number of decimal digits in a positive smi. |
| static int _positiveBase10Length(var smi) { |
| @@ -311,15 +310,12 @@ class _Smi extends _IntegerImplementation implements int { |
| if (smi < 1000000) return 6; |
| return 7; |
| } |
| - if (smi < _POW_10_10) { |
| - if (smi < _POW_10_8) return 8; |
| - if (smi < _POW_10_9) return 9; |
| - return 10; |
| - } |
| - smi = smi ~/ _POW_10_10; |
| - if (smi < 10) return 11; |
| - if (smi < 100) return 12; |
| - return 10 + _positiveBase10Length(smi); |
| + if (smi < _POW_10_8) return 8; |
| + if (smi < _POW_10_9) return 9; |
| + smi = smi ~/ _POW_10_9; |
| + if (smi < 10) return 10; |
| + if (smi < 100) return 11; |
|
Anders Johnsen
2014/04/22 09:21:48
Add comment why we check for 10 and 11 here.
|
| + return 9 + _positiveBase10Length(smi); |
| } |
| String toString() { |
| @@ -373,15 +369,12 @@ class _Smi extends _IntegerImplementation implements int { |
| if (negSmi > -1000000) return 6; |
| return 7; |
| } |
| - if (negSmi > -_POW_10_10) { |
| - if (negSmi > -_POW_10_8) return 8; |
| - if (negSmi > -_POW_10_9) return 9; |
| - return 10; |
| - } |
| - negSmi = negSmi ~/ _POW_10_10; |
| - if (negSmi > -10) return 11; |
| - if (negSmi > -100) return 12; |
| - return 10 + _negativeBase10Length(negSmi); |
| + if (negSmi > -_POW_10_8) return 8; |
| + if (negSmi > -_POW_10_9) return 9; |
| + negSmi = negSmi ~/ _POW_10_9; |
| + if (negSmi > -10) return 10; |
| + if (negSmi > -100) return 11; |
|
Anders Johnsen
2014/04/22 09:21:48
Ditto.
|
| + return 9 + _negativeBase10Length(negSmi); |
| } |
| // Convert a negative smi to a string. |