com php-src: eliminate one branch when computing the initial table size: Zend/zend_hash.c

From: Date: Wed, 22 Oct 2014 17:23:29 +0000
Subject: com php-src: eliminate one branch when computing the initial table size: Zend/zend_hash.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82444@lists.php.net to get a copy of this message
Commit: d5ccf4d276d7c6c3e03fda3a13700cc3cd518482 Author: Anatol Belski <ab@php.net> Wed, 22 Oct 2014 19:23:29 +0200 Parents: 9a969fdd3b8f4af2b8f36dfbb5aa26f8630ae4f5 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d5ccf4d276d7c6c3e03fda3a13700cc3cd518482 Log: eliminate one branch when computing the initial table size Changed paths: M Zend/zend_hash.c Diff: diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index d3423c8..3b1faf0 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -105,24 +105,22 @@ ZEND_API void _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestru if (nSize >= 0x80000000) { /* prevent overflow */ ht->nTableSize = 0x80000000; + } else if (nSize <= 8) { + ht->nTableSize = 8; } else { - if (nSize > 8) { #ifdef PHP_WIN32 - ht->nTableSize = 1U << __lzcnt(nSize); - if (ht->nTableSize < nSize) { - ht->nTableSize <<= 1; - } + ht->nTableSize = 1U << __lzcnt(nSize); + if (ht->nTableSize < nSize) { + ht->nTableSize <<= 1; + } #else - uint32_t i = 4; + uint32_t i = 4; - while ((1U << i) < nSize) { - i++; - } - ht->nTableSize = 1 << i; -#endif - } else { - ht->nTableSize = 8; + while ((1U << i) < nSize) { + i++; } + ht->nTableSize = 1 << i; +#endif } ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */

« previous php.cvs (#82444) next »