]> granicus.if.org Git - php/commitdiff
Optimized detection of "__call" and "__callstatic" methods.
authorDmitry Stogov <dmitry@php.net>
Tue, 25 Mar 2008 13:04:03 +0000 (13:04 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 25 Mar 2008 13:04:03 +0000 (13:04 +0000)
Zend/zend_API.c

index 9cc9b7d023ab8c81a8fb07d61677bcefabea6695..bfa2dcf296c812704a01943148808199a13dae47 100644 (file)
@@ -2627,8 +2627,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRML
 
 ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, char **callable_name, char **error TSRMLS_DC) /* {{{ */
 {
-       int lc_len;
-       char *lcname;
+       int len;
        zend_class_entry *ce;
        zend_function *func;
        zval **obj;
@@ -2647,22 +2646,23 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_i
        fci->no_separation = 1;
        fci->symbol_table = NULL;
 
-       lc_len = strlen(func->common.function_name);
-       lcname = zend_str_tolower_dup(func->common.function_name, lc_len);
-       if ((lc_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME) - 1)) ||
-               (lc_len == sizeof(ZEND_CALLSTATIC_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALLSTATIC_FUNC_NAME, sizeof(ZEND_CALLSTATIC_FUNC_NAME) - 1))
-       ) {
-               fcc->initialized = 0;
-               fcc->function_handler = NULL;
-               fcc->calling_scope = NULL;
-               fcc->object_pp = NULL;
-       } else {
-               fcc->initialized = 1;
-               fcc->function_handler = func;
-               fcc->calling_scope = ce;
-               fcc->object_pp = obj;
+       if (ce) {
+               len = strlen(func->common.function_name);
+               if ((len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !zend_binary_strcasecmp(func->common.function_name, len, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME) - 1)) ||
+                       (len == sizeof(ZEND_CALLSTATIC_FUNC_NAME) - 1 && !zend_binary_strcasecmp(func->common.function_name, len, ZEND_CALLSTATIC_FUNC_NAME, sizeof(ZEND_CALLSTATIC_FUNC_NAME) - 1))
+               ) {
+                       fcc->initialized = 0;
+                       fcc->function_handler = NULL;
+                       fcc->calling_scope = NULL;
+                       fcc->object_pp = NULL;
+                       return SUCCESS;
+               }
        }
-       efree(lcname);
+
+       fcc->initialized = 1;
+       fcc->function_handler = func;
+       fcc->calling_scope = ce;
+       fcc->object_pp = obj;
 
        return SUCCESS;
 }