Skip to content

Commit

Permalink
Introduce zend_symtable_exists_ind() for API consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Mar 2, 2016
1 parent 1ce0ea7 commit ab80064
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *k
{
zend_ulong idx;

if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_exists(ht, idx);
} else {
return zend_hash_exists(ht, key);
}
}


static zend_always_inline int zend_symtable_exists_ind(HashTable *ht, zend_string *key)
{
zend_ulong idx;

if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_exists(ht, idx);
} else {
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -5429,7 +5429,7 @@ PHP_FUNCTION(array_key_exists)

switch (Z_TYPE_P(key)) {
case IS_STRING:
if (zend_symtable_exists(array, Z_STR_P(key))) {
if (zend_symtable_exists_ind(array, Z_STR_P(key))) {
RETURN_TRUE;
}
RETURN_FALSE;
Expand All @@ -5439,7 +5439,7 @@ PHP_FUNCTION(array_key_exists)
}
RETURN_FALSE;
case IS_NULL:
if (zend_hash_exists(array, ZSTR_EMPTY_ALLOC())) {
if (zend_hash_exists_ind(array, ZSTR_EMPTY_ALLOC())) {
RETURN_TRUE;
}
RETURN_FALSE;
Expand Down

0 comments on commit ab80064

Please sign in to comment.