From 262b9b388d10b46a1c443f46eb8651aaee00909f Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 15 Jun 2016 14:53:28 +0200 Subject: [PATCH] Make Numerical.solveQuadratic() optimizable for Chrome V8 Little change to help Chrome's V( optimize `Numerical.solveQuadratic()`. In my use case this resulted in an overall performance improvement of about 1.5%. For details see #1078 --- src/util/Numerical.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/Numerical.js b/src/util/Numerical.js index 41db0c4a..44050fbb 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -234,10 +234,8 @@ var Numerical = new function() { // We multiply with a factor to normalize the coefficients. // The factor is just the nearest exponent of 10, big enough // to raise all the coefficients to nearly [-1, +1] range. - var mult = pow(10, - abs(Math.floor(Math.log(gmC) * Math.LOG10E))); - if (!isFinite(mult)) - mult = 0; + var mult = gmC === 0 ? 0 : pow(10, + abs(Math.floor(Math.log(gmC) * Math.LOG10E))); a *= mult; b *= mult; c *= mult;