com php-src: Inline IS_LONG value calculation and avo id strtol() call.: Zend/zend_operators.c

From: Date: Tue, 05 May 2015 08:09:18 +0000
Subject: com php-src: Inline IS_LONG value calculation and avo id strtol() call.: Zend/zend_operators.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86590@lists.php.net to get a copy of this message
Commit: 5fc88a99689ba27e9e15fb4749bb980e1fe5e5fb Author: Dmitry Stogov <dmitry@zend.com> Tue, 5 May 2015 11:09:18 +0300 Parents: c50994dc0b1c9e7dfe0d21aed45079bfa15fec1d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5fc88a99689ba27e9e15fb4749bb980e1fe5e5fb Log: Inline IS_LONG value calculation and avoid strtol() call. Changed paths: M Zend/zend_operators.c Diff: diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 2c80432..e384031 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2624,6 +2624,8 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t int digits = 0, dp_or_e = 0; double local_dval = 0.0; zend_uchar type; + zend_long tmp_lval = 0; + int neg = 0; if (!length) { return 0; @@ -2641,7 +2643,10 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t } ptr = str; - if (*ptr == '-' || *ptr == '+') { + if (*ptr == '-') { + neg = 1; + ptr++; + } else if (*ptr == '+') { ptr++; } @@ -2657,6 +2662,7 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors == 1)); digits++, ptr++) { check_digits: if (ZEND_IS_DIGIT(*ptr)) { + tmp_lval = tmp_lval * 10 + (*ptr) - '0'; continue; } else if (*ptr == '.' && dp_or_e < 1) { goto process_double; @@ -2723,7 +2729,10 @@ process_double: } if (lval) { - *lval = ZEND_STRTOL(str, NULL, 10); + if (neg) { + tmp_lval = -tmp_lval; + } + *lval = tmp_lval; } return IS_LONG;

« previous php.cvs (#86590) next »