Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel/fcall.c optimizations #843

Merged
merged 23 commits into from Jul 15, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Even more code deduplication
  • Loading branch information
sjinks committed Jul 14, 2013
commit 3a2206c50093c6fe31d0a2ceadfc5a056673b6e1
47 changes: 2 additions & 45 deletions ext/kernel/fcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ int phalcon_call_user_func_array_noex(zval *return_value, zval *handler, zval *p
char *is_callable_error = NULL;
int status = FAILURE;

if (Z_TYPE_P(params) != IS_ARRAY) {
if (params && Z_TYPE_P(params) != IS_ARRAY) {
ZVAL_NULL(return_value);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for phalcon_call_user_func_array_noex()");
phalcon_memory_restore_stack(TSRMLS_C);
Expand Down Expand Up @@ -668,50 +668,7 @@ int phalcon_call_user_func_array_noex(zval *return_value, zval *handler, zval *p
*/
int phalcon_call_user_func(zval *return_value, zval *handler TSRMLS_DC){

zval *retval_ptr = NULL;
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
char *is_callable_error = NULL;
int status = FAILURE;

if (zend_fcall_info_init(handler, 0, &fci, &fci_cache, NULL, &is_callable_error TSRMLS_CC) == SUCCESS) {
if (is_callable_error) {
zend_error(E_STRICT, "%s", is_callable_error);
efree(is_callable_error);
}
status = SUCCESS;
} else {
if (is_callable_error) {
zend_error(E_WARNING, "%s", is_callable_error);
efree(is_callable_error);
} else {
status = SUCCESS;
}
}

if (likely(status == SUCCESS)) {

fci.param_count = 0;
fci.retval_ptr_ptr = &retval_ptr;

if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && fci.retval_ptr_ptr && *fci.retval_ptr_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr);
}

if (fci.params) {
efree(fci.params);
}
}

if (EG(exception)) {
status = FAILURE;
}

if (status == FAILURE) {
phalcon_memory_restore_stack(TSRMLS_C);
}

return status;
return phalcon_call_user_func_array(return_value, handler, NULL TSRMLS_CC);
}

/**
Expand Down