Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_add_lookup(HashTable *ht, const char *str, size_t len)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_lookup(HashTable *ht, const char *str, size_t len)
ZEND_API zval* ZEND_FASTCALL zend_hash_str_lookup(HashTable *ht, const char *str, size_t len)

For consistency with zend_hash_lookup(), zend_hash_index_lookup(). _lookup already implies _add.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's what I meant. Probably not a good idea to make commits at midnight ;)

{
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;
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_add_lookup(HashTable *ht, const char *str, size_t len);

#define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \
if (EXPECTED(HT_IS_PACKED(_ht))) { \
Expand Down
8 changes: 3 additions & 5 deletions ext/standard/iptc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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_add_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);
Expand Down