From eccdc48c565e5147133c67e05e0c81a81326e83f Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 30 Nov 2017 02:06:52 +0300 Subject: [PATCH] Use interned strings for function names --- ext/opcache/Optimizer/zend_func_info.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 957d53864e..8b4f128299 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -1691,9 +1691,12 @@ uint32_t zend_get_func_info(const zend_call_info *call_info, const zend_ssa *ssa uint32_t ret = 0; if (call_info->callee_func->type == ZEND_INTERNAL_FUNCTION) { + zval *zv; func_info_t *info; - if ((info = zend_hash_find_ptr(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2, ssa->rt_constants)))) != NULL) { + zv = zend_hash_find_ex(&func_info, Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2, ssa->rt_constants)), 1); + if (zv) { + info = Z_PTR_P(zv); if (UNEXPECTED(zend_optimizer_is_disabled_func(info->name, info->name_len))) { ret = MAY_BE_NULL; } else if (info->info_func) { @@ -1750,9 +1753,12 @@ int zend_func_info_startup(void) zend_hash_init(&func_info, sizeof(func_infos)/sizeof(func_info_t), NULL, NULL, 1); for (i = 0; i < sizeof(func_infos)/sizeof(func_info_t); i++) { - if (zend_hash_str_add_ptr(&func_info, func_infos[i].name, func_infos[i].name_len, (void**)&func_infos[i]) == NULL) { + zend_string *key = zend_string_init_interned(func_infos[i].name, func_infos[i].name_len, 1); + + if (zend_hash_add_ptr(&func_info, key, (void**)&func_infos[i]) == NULL) { fprintf(stderr, "ERROR: Duplicate function info for \"%s\"\n", func_infos[i].name); } + zend_string_release(key); } } -- 2.40.0