mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
standard: Avoid double hash table lookup in iptcparse()
Closes GH-20420.
This commit is contained in:
@@ -44,6 +44,7 @@ PHP 8.6 INTERNALS UPGRADE NOTES
|
||||
. The zend_get_call_trampoline_func() API now takes the __call or
|
||||
__callStatic zend_function* instead of a CE and a boolean argument.
|
||||
. The zend_set_hash_symbol() API has been removed.
|
||||
. Added zend_hash_str_lookup().
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
|
||||
@@ -1062,6 +1062,13 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *st
|
||||
return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_ADD_NEW);
|
||||
}
|
||||
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_str_lookup(HashTable *ht, const char *str, size_t len)
|
||||
{
|
||||
zend_ulong h = zend_hash_func(str, len);
|
||||
|
||||
return _zend_hash_str_add_or_update_i(ht, str, len, h, NULL, HASH_LOOKUP);
|
||||
}
|
||||
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h)
|
||||
{
|
||||
zval dummy;
|
||||
|
||||
@@ -218,6 +218,7 @@ static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_stri
|
||||
/* Find or add NULL, if doesn't exist */
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key);
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h);
|
||||
ZEND_API zval* ZEND_FASTCALL zend_hash_str_lookup(HashTable *ht, const char *str, size_t len);
|
||||
|
||||
#define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \
|
||||
if (EXPECTED(HT_IS_PACKED(_ht))) { \
|
||||
|
||||
@@ -308,7 +308,6 @@ PHP_FUNCTION(iptcparse)
|
||||
unsigned char *buffer, recnum, dataset;
|
||||
char *str, key[16];
|
||||
size_t str_len;
|
||||
zval values, *element;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_STRING(str, str_len)
|
||||
@@ -357,10 +356,9 @@ PHP_FUNCTION(iptcparse)
|
||||
array_init(return_value);
|
||||
}
|
||||
|
||||
if ((element = zend_hash_str_find(Z_ARRVAL_P(return_value), key, strlen(key))) == NULL) {
|
||||
array_init(&values);
|
||||
|
||||
element = zend_hash_str_update(Z_ARRVAL_P(return_value), key, strlen(key), &values);
|
||||
zval *element = zend_hash_str_lookup(Z_ARRVAL_P(return_value), key, strlen(key));
|
||||
if (Z_ISNULL_P(element)) {
|
||||
array_init(element);
|
||||
}
|
||||
|
||||
add_next_index_stringl(element, (char *) buffer+inx, len);
|
||||
|
||||
Reference in New Issue
Block a user