summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-12-04 13:21:35 +0300
committerDmitry Stogov <dmitry@zend.com>2017-12-04 13:21:35 +0300
commitcc12acefcd4de93a2e8bcd0fe7dc2e000f14159d (patch)
tree4d137ed61b3ecc446ddeb75106fe6984fdac4ca5
parent7b085635d71b44c15d1057049c0cf38ff15d4a09 (diff)
downloadphp-git-cc12acefcd4de93a2e8bcd0fe7dc2e000f14159d.tar.gz
Use cheaper functions
-rw-r--r--Zend/zend_builtin_functions.c8
-rw-r--r--Zend/zend_compile.c26
-rw-r--r--Zend/zend_constants.c30
-rw-r--r--Zend/zend_exceptions.c6
-rw-r--r--Zend/zend_execute_API.c6
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c6
-rw-r--r--ext/standard/array.c68
-rw-r--r--ext/standard/basic_functions.c8
-rw-r--r--ext/standard/var.c2
9 files changed, 85 insertions, 75 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index baac19dda9..8fb7965a43 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -686,9 +686,9 @@ ZEND_FUNCTION(error_reporting)
zend_ini_entry *p = EG(error_reporting_ini_entry);
if (!p) {
- p = zend_hash_find_ptr(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING));
- if (p) {
- EG(error_reporting_ini_entry) = p;
+ zval *zv = zend_hash_find_ex(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), 1);
+ if (zv) {
+ p = EG(error_reporting_ini_entry) = (zend_ini_entry*)Z_PTR_P(zv);
} else {
break;
}
@@ -2136,7 +2136,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /
while (i < first_extra_arg) {
arg_name = call->func->op_array.vars[i];
- arg = zend_hash_find_ind(call->symbol_table, arg_name);
+ arg = zend_hash_find_ex_ind(call->symbol_table, arg_name, 1);
if (arg) {
if (Z_OPT_REFCOUNTED_P(arg)) {
Z_ADDREF_P(arg);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a665066cad..e625fcfe42 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1062,7 +1062,7 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opline, HashTable *function_table, zend_bool compile_time) /* {{{ */
{
zend_function *function, *new_function;
- zval *lcname, *rtd_key;
+ zval *lcname, *rtd_key, *zv;
if (compile_time) {
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
@@ -1072,15 +1072,18 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opli
rtd_key = lcname + 1;
}
- function = zend_hash_find_ptr(function_table, Z_STR_P(rtd_key));
+ zv = zend_hash_find_ex(function_table, Z_STR_P(rtd_key), 1);
+ function = (zend_function*)Z_PTR_P(zv);
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, function, sizeof(zend_op_array));
if (zend_hash_add_ptr(function_table, Z_STR_P(lcname), new_function) == NULL) {
int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR;
zend_function *old_function;
- if ((old_function = zend_hash_find_ptr(function_table, Z_STR_P(lcname))) != NULL
- && old_function->type == ZEND_USER_FUNCTION
+ zv = zend_hash_find_ex(function_table, Z_STR_P(lcname), 1);
+ ZEND_ASSERT(zv != NULL);
+ old_function = (zend_function*)Z_PTR_P(zv);
+ if (old_function->type == ZEND_USER_FUNCTION
&& old_function->op_array.last > 0) {
zend_error_noreturn(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
ZSTR_VAL(function->common.function_name),
@@ -1103,7 +1106,7 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opli
ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const zend_op *opline, HashTable *class_table, zend_bool compile_time) /* {{{ */
{
zend_class_entry *ce;
- zval *lcname, *rtd_key;
+ zval *lcname, *rtd_key, *zv;
if (compile_time) {
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
@@ -1112,8 +1115,9 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze
lcname = RT_CONSTANT(opline, opline->op1);
rtd_key = lcname + 1;
}
- ce = zend_hash_find_ptr(class_table, Z_STR_P(rtd_key));
- ZEND_ASSERT(ce);
+ zv = zend_hash_find_ex(class_table, Z_STR_P(rtd_key), 1);
+ ZEND_ASSERT(zv);
+ ce = (zend_class_entry*)Z_PTR_P(zv);
ce->refcount++;
if (zend_hash_add_ptr(class_table, Z_STR_P(lcname), ce) == NULL) {
ce->refcount--;
@@ -1138,7 +1142,7 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze
ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array, const zend_op *opline, HashTable *class_table, zend_class_entry *parent_ce, zend_bool compile_time) /* {{{ */
{
zend_class_entry *ce;
- zval *lcname, *rtd_key;
+ zval *lcname, *rtd_key, *zv;
if (compile_time) {
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
@@ -1148,9 +1152,9 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
rtd_key = lcname + 1;
}
- ce = zend_hash_find_ptr(class_table, Z_STR_P(rtd_key));
+ zv = zend_hash_find_ex(class_table, Z_STR_P(rtd_key), 1);
- if (!ce) {
+ if (!zv) {
if (!compile_time) {
/* If we're in compile time, in practice, it's quite possible
* that we'll never reach this class declaration at runtime,
@@ -1162,6 +1166,8 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
return NULL;
}
+ ce = (zend_class_entry*)Z_PTR_P(zv);
+
if (zend_hash_exists(class_table, Z_STR_P(lcname))) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name));
}
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index d8b10b1e91..639c15807d 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -417,26 +417,30 @@ failure:
ZEND_API zend_constant* ZEND_FASTCALL zend_quick_get_constant(const zval *key, uint32_t flags)
{
- zend_constant *c;
+ zval *zv;
+ zend_constant *c = NULL;
- if ((c = zend_hash_find_ptr(EG(zend_constants), Z_STR_P(key))) == NULL) {
+ zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
+ if (zv) {
+ c = (zend_constant*)Z_PTR_P(zv);
+ } else {
key++;
- if ((c = zend_hash_find_ptr(EG(zend_constants), Z_STR_P(key))) == NULL ||
- (c->flags & CONST_CS) != 0) {
+ zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
+ if (zv && (((zend_constant*)Z_PTR_P(zv))->flags & CONST_CS) == 0) {
+ c = (zend_constant*)Z_PTR_P(zv);
+ } else {
if ((flags & (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) == (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) {
key++;
- if ((c = zend_hash_find_ptr(EG(zend_constants), Z_STR_P(key))) == NULL) {
+ zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
+ if (zv) {
+ c = (zend_constant*)Z_PTR_P(zv);
+ } else {
key++;
- if ((c = zend_hash_find_ptr(EG(zend_constants), Z_STR_P(key))) == NULL ||
- (c->flags & CONST_CS) != 0) {
-
- key--;
- c = NULL;
+ zv = zend_hash_find_ex(EG(zend_constants), Z_STR_P(key), 1);
+ if (zv && (((zend_constant*)Z_PTR_P(zv))->flags & CONST_CS) == 0) {
+ c = (zend_constant*)Z_PTR_P(zv);
}
}
- } else {
- key--;
- c = NULL;
}
}
}
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index c892f701e3..bd889647e8 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -547,14 +547,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
smart_str_append_long(str, num);
smart_str_appendc(str, ' ');
- file = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_FILE));
+ file = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_FILE), 1);
if (file) {
if (Z_TYPE_P(file) != IS_STRING) {
zend_error(E_WARNING, "Function name is no string");
smart_str_appends(str, "[unknown function]");
} else{
zend_long line;
- tmp = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_LINE));
+ tmp = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_LINE), 1);
if (tmp) {
if (Z_TYPE_P(tmp) == IS_LONG) {
line = Z_LVAL_P(tmp);
@@ -577,7 +577,7 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_TYPE));
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_FUNCTION));
smart_str_appendc(str, '(');
- tmp = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_ARGS));
+ tmp = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_ARGS), 1);
if (tmp) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
size_t last_len = ZSTR_LEN(str->s);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 04174d46b2..c8d1e49376 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -906,9 +906,9 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
}
if (!EG(autoload_func)) {
- zend_function *func = zend_hash_find_ptr(EG(function_table), ZSTR_KNOWN(ZEND_STR_MAGIC_AUTOLOAD));
- if (func) {
- EG(autoload_func) = func;
+ zval *zv = zend_hash_find_ex(EG(function_table), ZSTR_KNOWN(ZEND_STR_MAGIC_AUTOLOAD), 1);
+ if (zv) {
+ EG(autoload_func) = (zend_function*)Z_PTR_P(zv);
} else {
if (!key) {
zend_string_release(lc_name);
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index b914d23463..be8ded4736 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -480,7 +480,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
for (; p != end; p++) {
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
ZEND_ASSERT(p->key);
- t = zend_hash_find(target, p->key);
+ t = zend_hash_find_ex(target, p->key, 1);
if (UNEXPECTED(t != NULL)) {
if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key */
@@ -524,7 +524,7 @@ static void zend_accel_function_hash_copy_from_shm(HashTable *target, HashTable
for (; p != end; p++) {
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
ZEND_ASSERT(p->key);
- t = zend_hash_find(target, p->key);
+ t = zend_hash_find_ex(target, p->key, 1);
if (UNEXPECTED(t != NULL)) {
if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key */
@@ -567,7 +567,7 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source, uni
for (; p != end; p++) {
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;
ZEND_ASSERT(p->key);
- t = zend_hash_find(target, p->key);
+ t = zend_hash_find_ex(target, p->key, 1);
if (UNEXPECTED(t != NULL)) {
if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key - ignore and wait for runtime */
diff --git a/ext/standard/array.c b/ext/standard/array.c
index ce4c4d5939..7e927d8956 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1742,7 +1742,7 @@ static zend_long php_extract_ref_if_exists(zend_array *arr, zend_array *symbol_t
if (!var_name) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -1753,10 +1753,10 @@ static zend_long php_extract_ref_if_exists(zend_array *arr, zend_array *symbol_t
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("GLOBALS")-1 && !strcmp(ZSTR_VAL(var_name), "GLOBALS")) {
+ if (zend_string_equals_literal(var_name, "GLOBALS")) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -1786,7 +1786,7 @@ static zend_long php_extract_if_exists(zend_array *arr, zend_array *symbol_table
if (!var_name) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -1797,10 +1797,10 @@ static zend_long php_extract_if_exists(zend_array *arr, zend_array *symbol_table
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("GLOBALS")-1 && !strcmp(ZSTR_VAL(var_name), "GLOBALS")) {
+ if (zend_string_equals_literal(var_name, "GLOBALS")) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -1833,19 +1833,19 @@ static zend_long php_extract_ref_overwrite(zend_array *arr, zend_array *symbol_t
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
}
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
}
- if (ZSTR_LEN(var_name) == sizeof("GLOBALS")-1 && !strcmp(ZSTR_VAL(var_name), "GLOBALS")) {
+ if (zend_string_equals_literal(var_name, "GLOBALS")) {
continue;
}
ZVAL_MAKE_REF(entry);
@@ -1878,19 +1878,19 @@ static zend_long php_extract_overwrite(zend_array *arr, zend_array *symbol_table
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
}
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
}
- if (ZSTR_LEN(var_name) == sizeof("GLOBALS")-1 && !strcmp(ZSTR_VAL(var_name), "GLOBALS")) {
+ if (zend_string_equals_literal(var_name, "GLOBALS")) {
continue;
}
ZVAL_DEREF(entry);
@@ -1920,7 +1920,7 @@ static zend_long php_extract_ref_prefix_if_exists(zend_array *arr, zend_array *s
if (!var_name) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -1934,7 +1934,7 @@ static zend_long php_extract_ref_prefix_if_exists(zend_array *arr, zend_array *s
}
php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -1973,7 +1973,7 @@ static zend_long php_extract_prefix_if_exists(zend_array *arr, zend_array *symbo
if (!var_name) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -1986,7 +1986,7 @@ static zend_long php_extract_prefix_if_exists(zend_array *arr, zend_array *symbo
}
php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2029,7 +2029,7 @@ static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol
if (ZSTR_LEN(var_name) == 0) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -2043,7 +2043,7 @@ static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol
}
php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2068,7 +2068,7 @@ static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2100,7 +2100,7 @@ static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_tab
if (ZSTR_LEN(var_name) == 0) {
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -2113,7 +2113,7 @@ static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_tab
}
php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1);
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2139,7 +2139,7 @@ static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_tab
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2177,7 +2177,7 @@ static zend_long php_extract_ref_prefix_all(zend_array *arr, zend_array *symbol_
zend_string_release(str);
}
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2224,7 +2224,7 @@ static zend_long php_extract_prefix_all(zend_array *arr, zend_array *symbol_tabl
zend_string_release(str);
}
if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) {
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2280,7 +2280,7 @@ static zend_long php_extract_ref_prefix_invalid(zend_array *arr, zend_array *sym
continue;
}
}
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2334,7 +2334,7 @@ static zend_long php_extract_prefix_invalid(zend_array *arr, zend_array *symbol_
continue;
}
}
- if (Z_STRLEN(final_name) == sizeof("this")-1 && !strcmp(Z_STRVAL(final_name), "this")) {
+ if (zend_string_equals_literal(Z_STR(final_name), "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
@@ -2375,14 +2375,14 @@ static zend_long php_extract_ref_skip(zend_array *arr, zend_array *symbol_table)
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
}
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -2419,14 +2419,14 @@ static zend_long php_extract_skip(zend_array *arr, zend_array *symbol_table) /*
if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) {
continue;
}
- if (ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this")) {
+ if (zend_string_equals_literal(var_name, "this")) {
if (!exception_thrown) {
exception_thrown = 1;
zend_throw_error(NULL, "Cannot re-assign $this");
}
continue;
}
- orig_var = zend_hash_find(symbol_table, var_name);
+ orig_var = zend_hash_find_ex(symbol_table, var_name, 1);
if (orig_var) {
if (Z_TYPE_P(orig_var) == IS_INDIRECT) {
orig_var = Z_INDIRECT_P(orig_var);
@@ -3614,7 +3614,7 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
ZEND_HASH_FOREACH_STR_KEY_VAL(src, string_key, src_entry) {
if (string_key) {
- if ((dest_entry = zend_hash_find(dest, string_key)) != NULL) {
+ if ((dest_entry = zend_hash_find_ex(dest, string_key, 1)) != NULL) {
zval *src_zval = src_entry;
zval *dest_zval = dest_entry;
HashTable *thash;
@@ -3725,7 +3725,7 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src) /* {{{ *
ZVAL_DEREF(src_zval);
if (string_key) {
if (Z_TYPE_P(src_zval) != IS_ARRAY ||
- (dest_entry = zend_hash_find(dest, string_key)) == NULL ||
+ (dest_entry = zend_hash_find_ex(dest, string_key, 1)) == NULL ||
(Z_TYPE_P(dest_entry) != IS_ARRAY &&
(!Z_ISREF_P(dest_entry) || Z_TYPE_P(Z_REFVAL_P(dest_entry)) != IS_ARRAY))) {
@@ -4661,7 +4661,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
} else {
ok = 1;
for (i = 1; i < argc; i++) {
- if ((data = zend_hash_find_ind(Z_ARRVAL(args[i]), p->key)) == NULL ||
+ if ((data = zend_hash_find_ex_ind(Z_ARRVAL(args[i]), p->key, 1)) == NULL ||
(intersect_data_compare_func &&
intersect_data_compare_func(val, data) != 0)
) {
@@ -5073,7 +5073,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
} else {
ok = 1;
for (i = 1; i < argc; i++) {
- if ((data = zend_hash_find_ind(Z_ARRVAL(args[i]), p->key)) != NULL &&
+ if ((data = zend_hash_find_ex_ind(Z_ARRVAL(args[i]), p->key, 1)) != NULL &&
(!diff_data_compare_func ||
diff_data_compare_func(val, data) == 0)
) {
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 0b5262487b..278ed08ff6 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4361,8 +4361,8 @@ PHP_FUNCTION(getopt)
* in order to be on the safe side, even though it is also available
* from the symbol table. */
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
- ((args = zend_hash_find_ind(Z_ARRVAL_P(&PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV))) != NULL ||
- (args = zend_hash_find_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV))) != NULL)
+ ((args = zend_hash_find_ex_ind(Z_ARRVAL_P(&PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL ||
+ (args = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL)
) {
int pos = 0;
zval *entry;
@@ -5963,12 +5963,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
zend_ulong key = (zend_ulong) zend_atol(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
array_init(&hash);
- find_hash = zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash);
+ find_hash = zend_hash_index_add_new(Z_ARRVAL_P(arr), key, &hash);
}
} else {
if ((find_hash = zend_hash_find(Z_ARRVAL_P(arr), Z_STR_P(arg1))) == NULL) {
array_init(&hash);
- find_hash = zend_hash_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), &hash);
+ find_hash = zend_hash_add_new(Z_ARRVAL_P(arr), Z_STR_P(arg1), &hash);
}
}
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 70f9ab65f2..0c32f32b65 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -741,7 +741,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
ZEND_HASH_FOREACH_STR_KEY(&names, name) {
zend_string *prot_name, *priv_name;
- zval *val = zend_hash_find(propers, name);
+ zval *val = zend_hash_find_ex(propers, name, 1);
if (val != NULL) {
if (Z_TYPE_P(val) == IS_INDIRECT) {
val = Z_INDIRECT_P(val);