diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-05-19 01:20:56 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-05-19 01:20:56 +0400 |
commit | 21da8af578b9359cb1568cb2a184c28e93b916e4 (patch) | |
tree | a9cc78860364cbd56e8c1d28197d39891f1cea7f | |
parent | d07c1941ec49758766c3482e41b5d559c0a866f6 (diff) | |
download | php-git-21da8af578b9359cb1568cb2a184c28e93b916e4.tar.gz |
Removed the old hack that was originally developed to support constants in array indeces, and isn't needed anymore after the Bob's patch.
-rw-r--r-- | Zend/zend_hash.c | 106 | ||||
-rw-r--r-- | Zend/zend_hash.h | 14 |
2 files changed, 0 insertions, 120 deletions
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index e374841978..695f05d225 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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) { diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index ed0dbbd627..6f6d9f0ec7 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -35,11 +35,6 @@ #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; |