mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Remove HASH_NEXT_INSERT flag
We already pass ht->nNextFreeElement and the rest is handled by ZEND_HASH_ADD.
This commit is contained in:
parent
0bf55b65d4
commit
311a67a2ed
4 changed files with 18 additions and 23 deletions
|
@ -402,7 +402,7 @@ ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *str, s
|
|||
return zend_hash_str_add(ht, str, len, &dummy);
|
||||
}
|
||||
|
||||
static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC)
|
||||
static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint32_t nIndex;
|
||||
uint32_t idx;
|
||||
|
@ -412,17 +412,13 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab
|
|||
#endif
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
|
||||
if (flag & HASH_NEXT_INSERT) {
|
||||
h = ht->nNextFreeElement;
|
||||
}
|
||||
CHECK_INIT(ht, h < ht->nTableSize);
|
||||
|
||||
if (ht->u.flags & HASH_FLAG_PACKED) {
|
||||
if (h < ht->nNumUsed) {
|
||||
p = ht->arData + h;
|
||||
if (Z_TYPE(p->val) != IS_UNDEF) {
|
||||
if (flag & (HASH_NEXT_INSERT | HASH_ADD)) {
|
||||
if (flag & HASH_ADD) {
|
||||
return NULL;
|
||||
}
|
||||
if (ht->pDestructor) {
|
||||
|
@ -479,7 +475,7 @@ convert_to_hash:
|
|||
if ((flag & HASH_ADD_NEW) == 0) {
|
||||
p = zend_hash_index_find_bucket(ht, h);
|
||||
if (p) {
|
||||
if (flag & (HASH_NEXT_INSERT | HASH_ADD)) {
|
||||
if (flag & HASH_ADD) {
|
||||
return NULL;
|
||||
}
|
||||
ZEND_ASSERT(&p->val != pData);
|
||||
|
@ -519,34 +515,34 @@ convert_to_hash:
|
|||
return &p->val;
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC)
|
||||
ZEND_API zval *_zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, flag ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, h, pData, flag ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_ADD ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_ADD | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_next_index_insert(HashTable *ht, zval *pData ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, ht->nNextFreeElement, pData, HASH_NEXT_INSERT ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, ht->nNextFreeElement, pData, HASH_ADD ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_FILE_LINE_DC)
|
||||
{
|
||||
return _zend_hash_index_update_or_next_insert_i(ht, ht->nNextFreeElement, pData, HASH_NEXT_INSERT | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC);
|
||||
return _zend_hash_index_add_or_update_i(ht, ht->nNextFreeElement, pData, HASH_ADD | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
|
||||
static void zend_hash_do_resize(HashTable *ht)
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
|
||||
#define HASH_UPDATE (1<<0)
|
||||
#define HASH_ADD (1<<1)
|
||||
#define HASH_NEXT_INSERT (1<<2)
|
||||
#define HASH_UPDATE_INDIRECT (1<<3)
|
||||
#define HASH_ADD_NEW (1<<4)
|
||||
#define HASH_UPDATE_INDIRECT (1<<2)
|
||||
#define HASH_ADD_NEW (1<<3)
|
||||
|
||||
#define INVALID_IDX ((uint32_t) -1)
|
||||
|
||||
|
@ -97,7 +96,7 @@ ZEND_API zval *_zend_hash_str_add_new(HashTable *ht, const char *key, size_t len
|
|||
#define zend_hash_str_add_new(ht, key, len, pData) \
|
||||
_zend_hash_str_add_new(ht, key, len, pData ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API zval *_zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
|
||||
ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
|
||||
ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData ZEND_FILE_LINE_DC);
|
||||
|
|
|
@ -110,12 +110,12 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv
|
|||
return retval;
|
||||
}
|
||||
|
||||
ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
|
||||
ZEND_API zval *_zend_ts_hash_index_add_or_update(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
|
||||
{
|
||||
zval *retval;
|
||||
|
||||
begin_write(ht);
|
||||
retval = _zend_hash_index_update_or_next_insert(TS_HASH(ht), h, pData, flag ZEND_FILE_LINE_RELAY_CC);
|
||||
retval = _zend_hash_index_add_or_update(TS_HASH(ht), h, pData, flag ZEND_FILE_LINE_RELAY_CC);
|
||||
end_write(ht);
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -55,11 +55,11 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv
|
|||
#define zend_ts_hash_add(ht, key, pData) \
|
||||
_zend_ts_hash_add_or_update(ht, key, pData, HASH_ADD ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
|
||||
ZEND_API zval *_zend_ts_hash_index_add_or_update(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC);
|
||||
#define zend_ts_hash_index_update(ht, h, pData) \
|
||||
_zend_ts_hash_index_update_or_next_insert(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_CC)
|
||||
_zend_ts_hash_index_add_or_update(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_CC)
|
||||
#define zend_ts_hash_next_index_insert(ht, pData) \
|
||||
_zend_ts_hash_index_update_or_next_insert(ht, 0, pData, HASH_NEXT_INSERT ZEND_FILE_LINE_CC)
|
||||
_zend_ts_hash_index_add_or_update(ht, ht->nNextFreeElement, pData, HASH_ADD ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API zval* zend_ts_hash_add_empty_element(TsHashTable *ht, zend_string *key);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue