Use cheaper API

This commit is contained in:
Xinchen Hui 2017-12-18 11:55:14 +08:00
parent 744d3c5753
commit 4dfbfe93aa
5 changed files with 18 additions and 5 deletions

View File

@ -807,6 +807,19 @@ static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_str
}
}
static zend_always_inline void *zend_hash_find_ex_ptr(const HashTable *ht, zend_string *key, zend_bool known_hash)
{
zval *zv;
zv = zend_hash_find_ex(ht, key, known_hash);
if (zv) {
ZEND_ASSUME(Z_PTR_P(zv));
return Z_PTR_P(zv);
} else {
return NULL;
}
}
static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len)
{
zval *zv;

View File

@ -1729,7 +1729,7 @@ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **f
ce = Z_OBJCE_P(obj);
if ((func = zend_hash_find(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) == NULL) {
if ((func = zend_hash_find_ex(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE), 1)) == NULL) {
return FAILURE;
}
*fptr_ptr = Z_FUNC_P(func);

View File

@ -165,7 +165,7 @@ static zend_object_handlers reflection_object_handlers;
static zval *_default_load_name(zval *object) /* {{{ */
{
return zend_hash_find_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME));
return zend_hash_find_ex_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME), 1);
}
/* }}} */

View File

@ -817,8 +817,8 @@ static zend_bool php_auto_globals_create_server(zend_string *name)
if (SG(request_info).argc) {
zval *argc, *argv;
if ((argc = zend_hash_find_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGC))) != NULL &&
(argv = zend_hash_find_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV))) != NULL) {
if ((argc = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGC), 1)) != NULL &&
(argv = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL) {
Z_ADDREF_P(argv);
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV), argv);
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGC), argc);

View File

@ -1814,7 +1814,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
}
/* Check again, the original check might have not known the protocol name */
if ((wrapper = zend_hash_find_ptr(wrapper_hash, ZSTR_KNOWN(ZEND_STR_FILE))) != NULL) {
if ((wrapper = zend_hash_find_ex_ptr(wrapper_hash, ZSTR_KNOWN(ZEND_STR_FILE), 1)) != NULL) {
return wrapper;
}