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

Possible improvement to function name lookups #108

Open
asgrim opened this issue Jun 14, 2022 · 0 comments
Open

Possible improvement to function name lookups #108

asgrim opened this issue Jun 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@asgrim
Copy link
Collaborator

asgrim commented Jun 14, 2022

const char* determine_function_name(zend_execute_data *execute_data)
{
int len;
char *ret;
if (!execute_data->func) {
return strdup("<not a function call>");
}
if (execute_data->func->common.scope && execute_data->func->common.fn_flags & ZEND_ACC_STATIC) {
DYNAMIC_MALLOC_SPRINTF(ret, len, "%s::%s",
ZSTR_VAL(Z_CE(execute_data->This)->name),
ZSTR_VAL(execute_data->func->common.function_name)
);
return ret;
}
if (Z_TYPE(execute_data->This) == IS_OBJECT) {
DYNAMIC_MALLOC_SPRINTF(ret, len, "%s->%s",
ZSTR_VAL(execute_data->func->common.scope->name),
ZSTR_VAL(execute_data->func->common.function_name)
);
return ret;
}
return strdup(ZSTR_VAL(execute_data->func->common.function_name));
}

beberlei suggested that we could possibly remove the need to form the "function name" every time if we make the lookup used a multi-dimensional array. Need to check all its use cases and see if it is indeed possible, as would be good to avoid allocating the string every time a function is called.

@asgrim asgrim added the enhancement New feature or request label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant