Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1d4f34d

Browse files
committed
Zend: refactor zend_call_method_if_exists() API
No need to call zend_is_callable_ex() when we have all the necessary information available to us The only "hard" part is if the object has a trampoline
1 parent a402eda commit 1d4f34d

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

‎Zend/zend_execute_API.c‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,22 +1130,27 @@ ZEND_API zend_result zend_call_method_if_exists(
11301130
zend_object *object, zend_string *method_name, zval *retval,
11311131
uint32_t param_count, zval *params)
11321132
{
1133-
zend_fcall_info fci;
1134-
fci.size = sizeof(zend_fcall_info);
1135-
fci.object = object;
1136-
ZVAL_STR(&fci.function_name, method_name);
1137-
fci.retval = retval;
1138-
fci.param_count = param_count;
1139-
fci.params = params;
1140-
fci.named_params = NULL;
1141-
1142-
zend_fcall_info_cache fcc;
1143-
if (!zend_is_callable_ex(&fci.function_name, fci.object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) {
1144-
ZVAL_UNDEF(retval);
1145-
return FAILURE;
1133+
zend_class_entry *ce = object->ce;
1134+
zend_function *fn = zend_hash_find_ptr_lc(&ce->function_table, method_name);
1135+
bool is_trampoline = false;
1136+
1137+
if (UNEXPECTED(fn == NULL)) {
1138+
/* We don't have a trampoline */
1139+
if (!ce->__call) {
1140+
ZVAL_UNDEF(retval);
1141+
return FAILURE;
1142+
}
1143+
is_trampoline = true;
1144+
fn = zend_get_call_trampoline_func(ce, method_name, false);
11461145
}
11471146

1148-
return zend_call_function(&fci, &fcc);
1147+
zend_call_known_function(fn, object, ce, retval, param_count, params, NULL);
1148+
1149+
if (is_trampoline) {
1150+
zend_string_release_ex(fn->common.function_name, 0);
1151+
zend_free_trampoline(fn);
1152+
}
1153+
return SUCCESS;
11491154
}
11501155

11511156
/* 0-9 a-z A-Z _ \ 0x80-0xff */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /