From 31c0af245e7601f3c3c870c20a57e9cf8634bb7b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 18 Mar 2009 10:18:10 +0000 Subject: Fixed floating point mathematic speed degradation (Christian) --- ext/standard/math.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'ext/standard/math.c') diff --git a/ext/standard/math.c b/ext/standard/math.c index b8a0b927d9..f1e1a42aeb 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -24,7 +24,6 @@ #include "php.h" #include "php_math.h" #include "zend_multiply.h" -#include "zend_float.h" #include #include @@ -94,10 +93,8 @@ static inline double php_intpow10(int power) { /* {{{ php_round_helper Actually performs the rounding of a value to integer in a certain mode */ static inline double php_round_helper(double value, int mode) { - ZEND_FLOAT_DECLARE double tmp_value; - ZEND_FLOAT_ENSURE(); if (value >= 0.0) { tmp_value = floor(value + 0.5); if ((mode == PHP_ROUND_HALF_DOWN && value == (-0.5 + tmp_value)) || @@ -116,7 +113,7 @@ static inline double php_round_helper(double value, int mode) { } } - ZEND_FLOAT_RETURN(tmp_value); + return tmp_value; } /* }}} */ @@ -126,13 +123,10 @@ static inline double php_round_helper(double value, int mode) { * mode. For the specifics of the algorithm, see http://wiki.php.net/rfc/rounding */ PHPAPI double _php_math_round(double value, int places, int mode) { - ZEND_FLOAT_DECLARE double f1, f2; double tmp_value; int precision_places; - ZEND_FLOAT_ENSURE(); - precision_places = 14 - php_intlog10abs(value); f1 = php_intpow10(abs(places)); @@ -163,7 +157,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) { } /* This value is beyond our precision, so rounding it is pointless */ if (fabs(tmp_value) >= 1e15) { - ZEND_FLOAT_RETURN(value); + return value; } } @@ -196,7 +190,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) { } } - ZEND_FLOAT_RETURN(tmp_value); + return tmp_value; } /* }}} */ -- cgit v1.2.1