Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class _Double implements double { | 5 class _Double implements double { |
| 6 factory _Double.fromInteger(int value) | 6 factory _Double.fromInteger(int value) |
| 7 native "Double_doubleFromInteger"; | 7 native "Double_doubleFromInteger"; |
| 8 | 8 |
| 9 Type get runtimeType => double; | 9 Type get runtimeType => double; |
| 10 | 10 |
| 11 int get _identityHashCode { | 11 // Code is replicated to avoid unnecessary dispath overhead. |
|
sra1
2016/07/08 21:35:59
They could both call a common static method.
Since
bakster
2016/07/08 22:04:22
I'll add a todo in the code for now. A static only
| |
| 12 if (isNaN || isInfinite) return 0; | 12 int get hashCode => (isNaN || isInfinite) ? 0 : toInt(); |
| 13 return toInt(); | 13 int get _identityHashCode => (isNaN || isInfinite) ? 0 : toInt(); |
| 14 } | 14 |
| 15 double operator +(num other) { | 15 double operator +(num other) { |
| 16 return _add(other.toDouble()); | 16 return _add(other.toDouble()); |
| 17 } | 17 } |
| 18 double _add(double other) native "Double_add"; | 18 double _add(double other) native "Double_add"; |
| 19 | 19 |
| 20 double operator -(num other) { | 20 double operator -(num other) { |
| 21 return _sub(other.toDouble()); | 21 return _sub(other.toDouble()); |
| 22 } | 22 } |
| 23 double _sub(double other) native "Double_sub"; | 23 double _sub(double other) native "Double_sub"; |
| 24 | 24 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 return EQUAL; | 269 return EQUAL; |
| 270 } | 270 } |
| 271 } else if (isNaN) { | 271 } else if (isNaN) { |
| 272 return other.isNaN ? EQUAL : GREATER; | 272 return other.isNaN ? EQUAL : GREATER; |
| 273 } else { | 273 } else { |
| 274 // Other is NaN. | 274 // Other is NaN. |
| 275 return LESS; | 275 return LESS; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 } | 278 } |
| OLD | NEW |