From: Nikita Popov Date: Tue, 16 Sep 2014 12:09:32 +0000 (+0200) Subject: Remove two more always-true conditions X-Git-Tag: POST_NATIVE_TLS_MERGE^2~262 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0bf55b65d47ab74fef22f35361a955a0b6704bff;p=php Remove two more always-true conditions --- diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index e651cd85e5..07ec4f32d3 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -416,65 +416,64 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab if (flag & HASH_NEXT_INSERT) { h = ht->nNextFreeElement; } - CHECK_INIT(ht, h >= 0 && h < ht->nTableSize); + CHECK_INIT(ht, h < ht->nTableSize); if (ht->u.flags & HASH_FLAG_PACKED) { - if (EXPECTED(h >= 0)) { - if (h < ht->nNumUsed) { - p = ht->arData + h; - if (Z_TYPE(p->val) != IS_UNDEF) { - if (flag & (HASH_NEXT_INSERT | HASH_ADD)) { - return NULL; - } - if (ht->pDestructor) { - ht->pDestructor(&p->val); - } - ZVAL_COPY_VALUE(&p->val, pData); - if ((zend_long)h >= (zend_long)ht->nNextFreeElement) { - ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX; - } - return &p->val; - } else { /* we have to keep the order :( */ - goto convert_to_hash; + if (h < ht->nNumUsed) { + p = ht->arData + h; + if (Z_TYPE(p->val) != IS_UNDEF) { + if (flag & (HASH_NEXT_INSERT | HASH_ADD)) { + return NULL; } - } else if (EXPECTED(h < ht->nTableSize)) { - p = ht->arData + h; - } else if (h < ht->nTableSize * 2 && - ht->nTableSize - ht->nNumOfElements < ht->nTableSize / 2) { - zend_hash_packed_grow(ht); - p = ht->arData + h; - } else { - goto convert_to_hash; - } - HANDLE_BLOCK_INTERRUPTIONS(); - /* incremental initialization of empty Buckets */ - if (h >= ht->nNumUsed) { - Bucket *q = ht->arData + ht->nNumUsed; - while (q != p) { - ZVAL_UNDEF(&q->val); - q++; + if (ht->pDestructor) { + ht->pDestructor(&p->val); } - ht->nNumUsed = h + 1; - } - ht->nNumOfElements++; - if (ht->nInternalPointer == INVALID_IDX) { - ht->nInternalPointer = h; + ZVAL_COPY_VALUE(&p->val, pData); + if ((zend_long)h >= (zend_long)ht->nNextFreeElement) { + ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX; + } + return &p->val; + } else { /* we have to keep the order :( */ + goto convert_to_hash; } - if ((zend_long)h >= (zend_long)ht->nNextFreeElement) { - ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX; + } else if (EXPECTED(h < ht->nTableSize)) { + p = ht->arData + h; + } else if (h < ht->nTableSize * 2 && + ht->nTableSize - ht->nNumOfElements < ht->nTableSize / 2) { + zend_hash_packed_grow(ht); + p = ht->arData + h; + } else { + goto convert_to_hash; + } + + HANDLE_BLOCK_INTERRUPTIONS(); + /* incremental initialization of empty Buckets */ + if (h >= ht->nNumUsed) { + Bucket *q = ht->arData + ht->nNumUsed; + while (q != p) { + ZVAL_UNDEF(&q->val); + q++; } - p->h = h; - p->key = NULL; - ZVAL_COPY_VALUE(&p->val, pData); - Z_NEXT(p->val) = INVALID_IDX; + ht->nNumUsed = h + 1; + } + ht->nNumOfElements++; + if (ht->nInternalPointer == INVALID_IDX) { + ht->nInternalPointer = h; + } + if ((zend_long)h >= (zend_long)ht->nNextFreeElement) { + ht->nNextFreeElement = h < ZEND_LONG_MAX ? h + 1 : ZEND_LONG_MAX; + } + p->h = h; + p->key = NULL; + ZVAL_COPY_VALUE(&p->val, pData); + Z_NEXT(p->val) = INVALID_IDX; - HANDLE_UNBLOCK_INTERRUPTIONS(); + HANDLE_UNBLOCK_INTERRUPTIONS(); + + return &p->val; - return &p->val; - } else { convert_to_hash: - zend_hash_packed_to_hash(ht); - } + zend_hash_packed_to_hash(ht); } if ((flag & HASH_ADD_NEW) == 0) {