com php-src: Compute needle end only after checking it's non-empty: Zend/zend_operators.h

From: Date: Wed, 28 Aug 2019 07:32:18 +0000
Subject: com php-src: Compute needle end only after checking it's non-empty: Zend/zend_operators.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108106@lists.php.net to get a copy of this message
Commit: 937d5f6598036d48713e28bf68df52cd56e1c974 Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 28 Aug 2019 09:32:18 +0200 Parents: 8cefd7c5ce5ccba7024dedf9da1b3743896fce2a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=937d5f6598036d48713e28bf68df52cd56e1c974 Log: Compute needle end only after checking it's non-empty Changed paths: M Zend/zend_operators.h Diff: diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index b42ad7f..ef88dfb 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -148,7 +148,6 @@ static zend_always_inline const char * zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = haystack; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; @@ -168,6 +167,7 @@ zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 9)) { /* glibc memchr is faster when needle is too short */ + const char ne = needle[needle_len-1]; end -= needle_len; while (p <= end) { @@ -210,7 +210,6 @@ static zend_always_inline const char * zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = end; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; @@ -230,6 +229,7 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 3)) { + const char ne = needle[needle_len-1]; p -= needle_len; do {

« previous php.cvs (#108106) next »