From ab800642df3e66bdc00b433234a4e38c156b731c Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 2 Mar 2016 11:53:47 +0300 Subject: [PATCH] Introduce zend_symtable_exists_ind() for API consistency --- Zend/zend_hash.h | 12 ++++++++++++ ext/standard/array.c | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index e90763ce8c..f4c2c30fbc 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -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 { diff --git a/ext/standard/array.c b/ext/standard/array.c index def7d7c465..4d2c45ec51 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -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; @@ -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; -- 2.40.0