]> granicus.if.org Git - php/commitdiff
Removed the old hack that was originally developed to support constants in array...
authorDmitry Stogov <dmitry@zend.com>
Sun, 18 May 2014 21:20:56 +0000 (01:20 +0400)
committerDmitry Stogov <dmitry@zend.com>
Sun, 18 May 2014 21:20:56 +0000 (01:20 +0400)
Zend/zend_hash.c
Zend/zend_hash.h

index e374841978fdd7b06ad2b37ab171e8b8af50fd0b..695f05d2251f3c8759523a0adff605b0923a1e85 100644 (file)
@@ -1466,112 +1466,6 @@ ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
        }
 }
 
-/* This function changes key of current element without changing elements'
- * order. If element with target key already exists, it will be deleted first.
- */
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode)
-{
-       uint idx1 = ht->nInternalPointer;
-       uint idx2;
-       Bucket *p, *q;
-       ulong h;
-#ifdef ZEND_SIGNALS
-       TSRMLS_FETCH();
-#endif
-
-       IS_CONSISTENT(ht);
-       if (idx1 != INVALID_IDX) {
-               p = ht->arData + idx1;
-               if (key_type == HASH_KEY_IS_LONG) {
-                       if (p->h == num_index && p->key == NULL) {
-                               return SUCCESS;
-                       }
-
-                       idx2 = ht->arHash[num_index & ht->nTableMask];
-                       while (idx2 != INVALID_IDX) {
-                               q = ht->arData + idx2;
-                               if (q->h == num_index && q->key == NULL) {
-                                       break;
-                               }
-                               idx2 = Z_NEXT(q->val);
-                       }
-               } else if (key_type == HASH_KEY_IS_STRING) {
-                       h = STR_HASH_VAL(str_index);
-                       if (p->key == str_index ||
-                           (p->h == h &&
-                            p->key &&
-                            p->key->len == str_index->len &&
-                            memcmp(p->key->val, str_index->val, str_index->len) == 0)) {
-                               return SUCCESS;
-                       }
-
-                       idx2 = ht->arHash[h & ht->nTableMask];
-                       while (idx2 != INVALID_IDX) {
-                               q = ht->arData + idx2;
-                               if (q->key == str_index ||
-                                   (q->h == h && q->key && q->key->len == str_index->len &&
-                                    memcmp(q->key->val, str_index->val, str_index->len) == 0)) {
-                                       break;
-                               }
-                               idx2 = Z_NEXT(q->val);
-                       }
-               } else {
-                       return FAILURE;
-               }
-
-               HANDLE_BLOCK_INTERRUPTIONS();
-
-               if (idx2 != INVALID_IDX) {
-                       /* we have another bucket with the key equal to new one */
-                       if (mode != HASH_UPDATE_KEY_ANYWAY) {
-                               int found = (idx1 < idx2) ? HASH_UPDATE_KEY_IF_BEFORE : HASH_UPDATE_KEY_IF_AFTER;
-
-                               if (mode & found) {
-                                       /* delete current bucket */
-                                       _zend_hash_del_el(ht, idx1, p);
-                                       HANDLE_UNBLOCK_INTERRUPTIONS();
-                                       return FAILURE;
-                               }
-                       }
-                       /* delete another bucket with the same key */
-                       _zend_hash_del_el(ht, idx2, q);
-               }
-
-               /* remove old key from hash */
-               if (ht->arHash[p->h & ht->nTableMask] == idx1) {
-                       ht->arHash[p->h & ht->nTableMask] = Z_NEXT(p->val);
-               } else {
-                       uint idx3 = ht->arHash[p->h & ht->nTableMask];
-                       while (Z_NEXT(ht->arData[idx3].val) != idx1) {
-                               idx3 = Z_NEXT(ht->arData[idx3].val);
-                       } 
-                       Z_NEXT(ht->arData[idx3].val) = Z_NEXT(p->val);
-               }
-
-               /* update key */
-               if (p->key) {
-                       STR_RELEASE(p->key);
-               }
-               if (key_type == HASH_KEY_IS_LONG) {
-                       p->h = num_index;
-                       p->key = NULL;
-               } else {
-                       p->h = h;
-                       p->key = str_index;
-                       STR_ADDREF(str_index);
-               }
-
-               /* insert new key into hash */
-               Z_NEXT(p->val) = ht->arHash[p->h & ht->nTableMask];
-               ht->arHash[p->h & ht->nTableMask] = idx1;
-               HANDLE_UNBLOCK_INTERRUPTIONS();
-
-               return SUCCESS;
-       } else {
-               return FAILURE;
-       }
-}
-
 ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
                                                        compare_func_t compar, int renumber TSRMLS_DC)
 {
index ed0dbbd627e81aad4be937a12238805b39d7e521..6f6d9f0ec7b2202f962a8e7ff83be3bcaafec76b 100644 (file)
 #define HASH_NEXT_INSERT               (1<<2)
 #define HASH_UPDATE_INDIRECT   (1<<3)
 
-#define HASH_UPDATE_KEY_IF_NONE    0
-#define HASH_UPDATE_KEY_IF_BEFORE  1
-#define HASH_UPDATE_KEY_IF_AFTER   2
-#define HASH_UPDATE_KEY_ANYWAY     3
-
 #define INVALID_IDX ((uint)-1)
 
 #define HASH_FLAG_PERSISTENT       (1<<0)
@@ -152,7 +147,6 @@ ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)
 ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
 ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
 ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos);
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode);
 
 typedef struct _HashPointer {
        HashPosition pos;
@@ -181,8 +175,6 @@ ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr);
        zend_hash_internal_pointer_reset_ex(ht, &(ht)->nInternalPointer)
 #define zend_hash_internal_pointer_end(ht) \
        zend_hash_internal_pointer_end_ex(ht, &(ht)->nInternalPointer)
-#define zend_hash_update_current_key(ht, key_type, str_index, str_length, num_index) \
-       zend_hash_update_current_key_ex(ht, key_type, str_index, str_length, num_index, HASH_UPDATE_KEY_ANYWAY)
 
 /* Copying, merging and sorting */
 ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor);
@@ -373,12 +365,6 @@ static inline int zend_symtable_str_exists(HashTable *ht, const char *str, int l
        return zend_hash_str_exists(ht, str, len);
 }
 
-static inline int zend_symtable_update_current_key_ex(HashTable *ht, zend_string *key, int mode)
-{
-ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_update_current_key_ex(ht, HASH_KEY_IS_LONG, NULL, idx, mode));
-       return zend_hash_update_current_key_ex(ht, HASH_KEY_IS_STRING, key, 0, mode);
-}
-
 static inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData)
 {
        zval tmp, *zv;