diff options
| author | Sterling Hughes <sterling@php.net> | 2003-05-20 18:28:14 +0000 |
|---|---|---|
| committer | Sterling Hughes <sterling@php.net> | 2003-05-20 18:28:14 +0000 |
| commit | ca6ca5e2a6c28c046447f71a597fdfde5b2a5697 (patch) | |
| tree | 4586cb1b8ad455e7dfd690f4db37bdaa0f36d18b | |
| parent | 3c6fd350074346af16324322d7d1605e6bf5670f (diff) | |
| download | php-git-ca6ca5e2a6c28c046447f71a597fdfde5b2a5697.tar.gz | |
optimize the lookups by avoiding a copy and then another pass
Naked Dancing Girls should be given to: Myself, Zeev, Marcus,
and George Schlossnagle (in no particular order)
| -rw-r--r-- | Zend/zend_execute_API.c | 15 | ||||
| -rw-r--r-- | Zend/zend_operators.c | 18 | ||||
| -rw-r--r-- | Zend/zend_operators.h | 1 |
3 files changed, 25 insertions, 9 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 34b576860f..3d04fe7747 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -540,9 +540,9 @@ int fast_call_user_function(HashTable *function_table, zval **object_pp, zval *f zval *orig_free_op1, *orig_free_op2; int (*orig_unary_op)(zval *result, zval *op1); int (*orig_binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC); - zval function_name_copy; zend_class_entry *current_scope; zend_class_entry *calling_scope = NULL; + char *function_name_lc; zval *current_this; zend_namespace *current_namespace = EG(active_namespace); zend_execute_data execute_data; @@ -595,8 +595,7 @@ int fast_call_user_function(HashTable *function_table, zval **object_pp, zval *f char *lc_class; int found; - lc_class = estrndup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp)); - zend_str_tolower(lc_class, Z_STRLEN_PP(object_pp)); + lc_class = zend_str_tolower_copy(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp)); found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); efree(lc_class); if (found == FAILURE) @@ -613,16 +612,14 @@ int fast_call_user_function(HashTable *function_table, zval **object_pp, zval *f return FAILURE; } - function_name_copy = *function_name; - zval_copy_ctor(&function_name_copy); - zend_str_tolower(function_name_copy.value.str.val, function_name_copy.value.str.len); + function_name_lc = zend_str_tolower_copy(function_name->value.str.val, function_name->value.str.len); original_function_state_ptr = EG(function_state_ptr); - if (zend_hash_find(function_table, function_name_copy.value.str.val, function_name_copy.value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { - zval_dtor(&function_name_copy); + if (zend_hash_find(function_table, function_name_lc, function_name->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { + efree(function_name_lc); return FAILURE; } - zval_dtor(&function_name_copy); + efree(function_name_lc); *function_pointer = EX(function_state).function; } else { EX(function_state).function = *function_pointer; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5a216afc93..f1caf779bb 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1579,6 +1579,24 @@ ZEND_API int zval_is_true(zval *op) return (op->value.lval ? 1 : 0); } +ZEND_API char *zend_str_tolower_copy(char *str, unsigned int length) +{ + register char *result; + register char *start; + register char *p = str; + register char *end = p + length; + + result = emalloc(length+1); + start = result; + + while (p < end) { + *result++ = tolower(*p++); + } + *result = *end; + + return start; +} + ZEND_API void zend_str_tolower(char *str, unsigned int length) { register char *p=str, *end=p+length; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 2819323e11..368426e952 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -197,6 +197,7 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); ZEND_API void zend_str_tolower(char *str, unsigned int length); +ZEND_API char *zend_str_tolower_copy(char *str, unsigned int length); ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2); ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3); ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2); |
