com php-src: In 95% cases we initialize "empty" array (with 8 hash slots).: Zend/zend_hash.c

From: Date: Mon, 24 Aug 2015 19:07:28 +0000
Subject: com php-src: In 95% cases we initialize "empty" array (with 8 hash slots).: Zend/zend_hash.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88743@lists.php.net to get a copy of this message
Commit: f9f568aa1e1564e068f2319af34d5834b3f3da09 Author: Dmitry Stogov <dmitry@zend.com> Mon, 24 Aug 2015 22:07:28 +0300 Parents: 96ea4a0ac603f20d0f3128eba7e5085001fb6f68 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f9f568aa1e1564e068f2319af34d5834b3f3da09 Log: In 95% cases we initialize "empty" array (with 8 hash slots). Changed paths: M Zend/zend_hash.c Diff: diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 4f19fdd..eaade17 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -136,7 +136,20 @@ static void zend_always_inline zend_hash_real_init_ex(HashTable *ht, int packed) (ht)->nTableMask = -(ht)->nTableSize; HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), (ht)->u.flags & HASH_FLAG_PERSISTENT)); (ht)->u.flags |= HASH_FLAG_INITIALIZED; - HT_HASH_RESET(ht); + if (EXPECTED(ht->nTableMask == -8)) { + Bucket *arData = ht->arData; + + HT_HASH_EX(arData, -8) = -1; + HT_HASH_EX(arData, -7) = -1; + HT_HASH_EX(arData, -6) = -1; + HT_HASH_EX(arData, -5) = -1; + HT_HASH_EX(arData, -4) = -1; + HT_HASH_EX(arData, -3) = -1; + HT_HASH_EX(arData, -2) = -1; + HT_HASH_EX(arData, -1) = -1; + } else { + HT_HASH_RESET(ht); + } } }

« previous php.cvs (#88743) next »