@@ -141,6 +141,21 @@ ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)
141141
142142static 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+
144159ZEND_API int _zend_hash_init (HashTable * ht , uint nSize , dtor_func_t pDestructor , zend_bool persistent ZEND_FILE_LINE_DC )
145160{
146161uint i = 3 ;
@@ -209,21 +224,14 @@ ZEND_API int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKe
209224p = ht -> arBuckets [nIndex ];
210225while (p != NULL ) {
211226if (p -> arKey == arKey ||
212- ((p -> h == h ) && (p -> nKeyLength == nKeyLength ) && !memcmp (p -> arKey , arKey , nKeyLength ))) {
213- if (flag & HASH_ADD ) {
214- return FAILURE ;
215- }
216- ZEND_ASSERT (p -> pData != pData );
217- HANDLE_BLOCK_INTERRUPTIONS ();
218- if (ht -> pDestructor ) {
219- ht -> pDestructor (p -> pData );
220- }
221- UPDATE_DATA (ht , p , pData , nDataSize );
222- if (pDest ) {
223- * pDest = p -> pData ;
224- }
225- HANDLE_UNBLOCK_INTERRUPTIONS ();
226- return SUCCESS ;
227+ ((p -> h == h ) && (p -> nKeyLength == nKeyLength )
228+ && !memcmp (p -> arKey , arKey , nKeyLength ))
229+ ) {
230+ if (flag & HASH_ADD ) {
231+ return FAILURE ;
232+ }
233+ zend_hash_bucket_update (ht , p , pData , nDataSize , pDest ZEND_FILE_LINE_RELAY_CC );
234+ return SUCCESS ;
227235}
228236p = p -> pNext ;
229237}
@@ -272,21 +280,14 @@ ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, const char *arKey, ui
272280p = ht -> arBuckets [nIndex ];
273281while (p != NULL ) {
274282if (p -> arKey == arKey ||
275- ((p -> h == h ) && (p -> nKeyLength == nKeyLength ) && !memcmp (p -> arKey , arKey , nKeyLength ))) {
276- if (flag & HASH_ADD ) {
277- return FAILURE ;
278- }
279- ZEND_ASSERT (p -> pData != pData );
280- HANDLE_BLOCK_INTERRUPTIONS ();
281- if (ht -> pDestructor ) {
282- ht -> pDestructor (p -> pData );
283- }
284- UPDATE_DATA (ht , p , pData , nDataSize );
285- if (pDest ) {
286- * pDest = p -> pData ;
287- }
288- HANDLE_UNBLOCK_INTERRUPTIONS ();
289- return SUCCESS ;
283+ ((p -> h == h ) && (p -> nKeyLength == nKeyLength )
284+ && !memcmp (p -> arKey , arKey , nKeyLength ))
285+ ) {
286+ if (flag & HASH_ADD ) {
287+ return FAILURE ;
288+ }
289+ zend_hash_bucket_update (ht , p , pData , nDataSize , pDest ZEND_FILE_LINE_RELAY_CC );
290+ return SUCCESS ;
290291}
291292p = p -> pNext ;
292293}
@@ -351,16 +352,7 @@ ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void
351352if (flag & HASH_NEXT_INSERT || flag & HASH_ADD ) {
352353return FAILURE ;
353354}
354- ZEND_ASSERT (p -> pData != pData );
355- HANDLE_BLOCK_INTERRUPTIONS ();
356- if (ht -> pDestructor ) {
357- ht -> pDestructor (p -> pData );
358- }
359- UPDATE_DATA (ht , p , pData , nDataSize );
360- HANDLE_UNBLOCK_INTERRUPTIONS ();
361- if (pDest ) {
362- * pDest = p -> pData ;
363- }
355+ zend_hash_bucket_update (ht , p , pData , nDataSize , pDest ZEND_FILE_LINE_RELAY_CC );
364356return SUCCESS ;
365357}
366358p = p -> pNext ;
0 commit comments