]> granicus.if.org Git - php/commitdiff
Remove two more always-true conditions
authorNikita Popov <nikic@php.net>
Tue, 16 Sep 2014 12:09:32 +0000 (14:09 +0200)
committerNikita Popov <nikic@php.net>
Tue, 16 Sep 2014 16:28:59 +0000 (18:28 +0200)
Zend/zend_hash.c

index e651cd85e5bfc2d7e25c1d4b41bcc6484863922f..07ec4f32d38ba0449659e8eb20170fb942c2b984 100644 (file)
@@ -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) {