Skip to content

Commit f331ed1

Browse files
committed
Revert "Add helper function for updating bucket contents"
Reverting this for now, because it would require further changes thanks to the zend signals tsrms-but-only-sometimes awesomeness.
1 parent 4e7e301 commit f331ed1

File tree

1 file changed

+40
-32
lines changed

1 file changed

+40
-32
lines changed

Zend/zend_hash.c

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,6 @@ ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)
141141

142142
static const Bucket *uninitialized_bucket = NULL;
143143

144-
static inline void zend_hash_bucket_update(
145-
const HashTable *ht, Bucket *p, void *pData, uint nDataSize, void **pDest ZEND_FILE_LINE_DC
146-
) {
147-
ZEND_ASSERT(p->pData != pData);
148-
HANDLE_BLOCK_INTERRUPTIONS();
149-
if (ht->pDestructor) {
150-
ht->pDestructor(p->pData);
151-
}
152-
UPDATE_DATA(ht, p, pData, nDataSize);
153-
HANDLE_UNBLOCK_INTERRUPTIONS();
154-
if (pDest) {
155-
*pDest = p->pData;
156-
}
157-
}
158-
159144
static zend_always_inline void i_zend_hash_bucket_delete(HashTable *ht, Bucket *p)
160145
{
161146
#ifdef ZEND_SIGNALS
@@ -269,14 +254,21 @@ ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKe
269254
p = ht->arBuckets[nIndex];
270255
while (p != NULL) {
271256
if (p->arKey == arKey ||
272-
((p->h == h) && (p->nKeyLength == nKeyLength)
273-
&& !memcmp(p->arKey, arKey, nKeyLength))
274-
) {
275-
if (flag & HASH_ADD) {
276-
return FAILURE;
277-
}
278-
zend_hash_bucket_update(ht, p, pData, nDataSize, pDest ZEND_FILE_LINE_RELAY_CC);
279-
return SUCCESS;
257+
((p->h == h) && (p->nKeyLength == nKeyLength) && !memcmp(p->arKey, arKey, nKeyLength))) {
258+
if (flag & HASH_ADD) {
259+
return FAILURE;
260+
}
261+
ZEND_ASSERT(p->pData != pData);
262+
HANDLE_BLOCK_INTERRUPTIONS();
263+
if (ht->pDestructor) {
264+
ht->pDestructor(p->pData);
265+
}
266+
UPDATE_DATA(ht, p, pData, nDataSize);
267+
if (pDest) {
268+
*pDest = p->pData;
269+
}
270+
HANDLE_UNBLOCK_INTERRUPTIONS();
271+
return SUCCESS;
280272
}
281273
p = p->pNext;
282274
}
@@ -325,14 +317,21 @@ ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, ui
325317
p = ht->arBuckets[nIndex];
326318
while (p != NULL) {
327319
if (p->arKey == arKey ||
328-
((p->h == h) && (p->nKeyLength == nKeyLength)
329-
&& !memcmp(p->arKey, arKey, nKeyLength))
330-
) {
331-
if (flag & HASH_ADD) {
332-
return FAILURE;
333-
}
334-
zend_hash_bucket_update(ht, p, pData, nDataSize, pDest ZEND_FILE_LINE_RELAY_CC);
335-
return SUCCESS;
320+
((p->h == h) && (p->nKeyLength == nKeyLength) && !memcmp(p->arKey, arKey, nKeyLength))) {
321+
if (flag & HASH_ADD) {
322+
return FAILURE;
323+
}
324+
ZEND_ASSERT(p->pData != pData);
325+
HANDLE_BLOCK_INTERRUPTIONS();
326+
if (ht->pDestructor) {
327+
ht->pDestructor(p->pData);
328+
}
329+
UPDATE_DATA(ht, p, pData, nDataSize);
330+
if (pDest) {
331+
*pDest = p->pData;
332+
}
333+
HANDLE_UNBLOCK_INTERRUPTIONS();
334+
return SUCCESS;
336335
}
337336
p = p->pNext;
338337
}
@@ -397,7 +396,16 @@ ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void
397396
if (flag & HASH_NEXT_INSERT || flag & HASH_ADD) {
398397
return FAILURE;
399398
}
400-
zend_hash_bucket_update(ht, p, pData, nDataSize, pDest ZEND_FILE_LINE_RELAY_CC);
399+
ZEND_ASSERT(p->pData != pData);
400+
HANDLE_BLOCK_INTERRUPTIONS();
401+
if (ht->pDestructor) {
402+
ht->pDestructor(p->pData);
403+
}
404+
UPDATE_DATA(ht, p, pData, nDataSize);
405+
HANDLE_UNBLOCK_INTERRUPTIONS();
406+
if (pDest) {
407+
*pDest = p->pData;
408+
}
401409
return SUCCESS;
402410
}
403411
p = p->pNext;

0 commit comments

Comments
 (0)