| 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 // Patch file for dart:math library. | 5 // Patch file for dart:math library. |
| 6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
| 7 import 'dart:_js_helper' show patch, checkNum; | 7 import 'dart:_js_helper' show patch, checkNum; |
| 8 import 'dart:typed_data' show ByteData; | 8 import 'dart:typed_data' show ByteData; |
| 9 | 9 |
| 10 @patch | 10 @patch |
| 11 T min<T extends num>(T a, T b) => | 11 T min<T extends num>(T a, T b) => JS( |
| 12 JS('num', r'Math.min(#, #)', checkNum(a), checkNum(b)) as T; | 12 'returns:num;depends:none;effects:none;gvn:true', |
| 13 r'Math.min(#, #)', |
| 14 checkNum(a), |
| 15 checkNum(b)); |
| 13 | 16 |
| 14 @patch | 17 @patch |
| 15 T max<T extends num>(T a, T b) => | 18 T max<T extends num>(T a, T b) => JS( |
| 16 JS('num', r'Math.max(#, #)', checkNum(a), checkNum(b)) as T; | 19 'returns:num;depends:none;effects:none;gvn:true', |
| 20 r'Math.max(#, #)', |
| 21 checkNum(a), |
| 22 checkNum(b)); |
| 17 | 23 |
| 18 @patch | 24 @patch |
| 19 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); | 25 double sqrt(num x) => JS('num', r'Math.sqrt(#)', checkNum(x)); |
| 20 | 26 |
| 21 @patch | 27 @patch |
| 22 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); | 28 double sin(num radians) => JS('num', r'Math.sin(#)', checkNum(radians)); |
| 23 | 29 |
| 24 @patch | 30 @patch |
| 25 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); | 31 double cos(num radians) => JS('num', r'Math.cos(#)', checkNum(radians)); |
| 26 | 32 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // last range of k*max .. 256**byteCount. | 324 // last range of k*max .. 256**byteCount. |
| 319 // TODO: Consider picking a higher byte count if the last range is a | 325 // TODO: Consider picking a higher byte count if the last range is a |
| 320 // significant portion of the entire range - a 50% chance of having | 326 // significant portion of the entire range - a 50% chance of having |
| 321 // to use two more bytes is no worse than always using one more. | 327 // to use two more bytes is no worse than always using one more. |
| 322 if (random - result + max < randomLimit) { | 328 if (random - result + max < randomLimit) { |
| 323 return result; | 329 return result; |
| 324 } | 330 } |
| 325 } | 331 } |
| 326 } | 332 } |
| 327 } | 333 } |
| OLD | NEW |