[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: Use =?UTF-8?Q?zend=5Fhash=5Ffind=28=29=20instead=20of=20zend?= =?UTF-8?Q?=5Fh
From:       Dmitry Stogov <dmitry () php ! net>
Date:       2017-12-27 10:25:21
Message-ID: php-mail-2ae9c7f0ed99488ea3f631ad4800043d373105006 () git ! php ! net
[Download RAW message or body]

Commit:    856ad54f4504e1659797f84f8b951e6f80918da3
Author:    Dmitry Stogov <dmitry@zend.com>         Wed, 27 Dec 2017 13:25:21 +0300
Parents:   d6b2756da16f3845d6ff46f3dbaea28dbe9c914e
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=856ad54f4504e1659797f84f8b951e6f80918da3

Log:
Use zend_hash_find() instead of zend_hash_find_ptr() to avoid double check

Changed paths:
  M  ext/pcre/php_pcre.c


Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 47f22a5..83cbad4 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -535,7 +535,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 	size_t				 pattern_len;
 	uint32_t			 poptions = 0;
 	const uint8_t       *tables = NULL;
-	pcre_cache_entry	*pce;
+	zval                *zv;
 	pcre_cache_entry	 new_entry;
 	int					 rc;
 	zend_string 		*key;
@@ -554,14 +554,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 
 	/* Try to lookup the cached regex entry, and if successful, just pass
 	   back the compiled pattern, otherwise go on and compile it. */
-	pce = zend_hash_find_ptr(&PCRE_G(pcre_cache), key);
-	if (pce) {
+	zv = zend_hash_find(&PCRE_G(pcre_cache), key);
+	if (zv) {
 #if HAVE_SETLOCALE
 		if (key != regex) {
 			zend_string_release(key);
 		}
 #endif
-		return pce;
+		return (pcre_cache_entry*)Z_PTR_P(zv);
 	}
 
 	p = ZSTR_VAL(regex);
@@ -768,7 +768,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 	 * these are supposedly the oldest ones (but not necessarily the least used
 	 * ones).
 	 */
-	if (!pce && zend_hash_num_elements(&PCRE_G(pcre_cache)) == PCRE_CACHE_SIZE) {
+	if (zend_hash_num_elements(&PCRE_G(pcre_cache)) == PCRE_CACHE_SIZE) {
 		int num_clean = PCRE_CACHE_SIZE / 8;
 		zend_hash_apply_with_argument(&PCRE_G(pcre_cache), pcre_clean_cache, &num_clean);
 	}
@@ -827,9 +827,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 		key = str;
 	}
 
-	pce = zend_hash_add_new_mem(&PCRE_G(pcre_cache), key, &new_entry, sizeof(pcre_cache_entry));
-
-	return pce;
+	return zend_hash_add_new_mem(&PCRE_G(pcre_cache), key, &new_entry, sizeof(pcre_cache_entry));
 }
 /* }}} */


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic