Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: runtime/lib/math_patch.dart

Issue 270743004: Refactor and improve code for pow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/typed_data.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/math_patch.dart
===================================================================
--- runtime/lib/math_patch.dart (revision 35942)
+++ runtime/lib/math_patch.dart (working copy)
@@ -19,6 +19,11 @@
if (exponent == 0.0) {
return 1.0; // ECMA-262 15.8.2.13
}
+ // Speed up simple cases.
+ if (exponent == 1.0) return base;
+ if (exponent == 2.0) return base * base;
+ if (exponent == 3.0) return base * base * base;
+
if (base == 1.0) return 1.0;
if (base.isNaN || exponent.isNaN) {
« no previous file with comments | « no previous file | runtime/lib/typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698