From a055e93a27adf1551eac6146d525fec9216b3d34 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 13 Dec 2006 15:31:47 +0000 Subject: [PATCH] optimize out strlen() calls # Patch by Matt Wilmas --- ext/standard/basic_functions.c | 4 ++-- ext/wddx/wddx.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 977f59cece1..65de5bc1499 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4665,13 +4665,13 @@ PHP_FUNCTION(getopt) } } else { /* other strings */ - if(zend_hash_find(HASH_OF(return_value), optname, strlen(optname)+1, (void **)&args) != FAILURE) { + if(zend_hash_find(HASH_OF(return_value), optname, optname_len + 1, (void **)&args) != FAILURE) { if(Z_TYPE_PP(args) != IS_ARRAY) { convert_to_array_ex(args); } zend_hash_next_index_insert(HASH_OF(*args), (void *)&val, sizeof(zval *), NULL); } else { - zend_hash_add(HASH_OF(return_value), optname, strlen(optname)+1, (void *)&val, sizeof(zval *), NULL); + zend_hash_add(HASH_OF(return_value), optname, optname_len + 1, (void *)&val, sizeof(zval *), NULL); } } } diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 887c5934611..29657b65b98 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -974,10 +974,11 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) add_property_zval(ent2->data, ent1->varname, ent1->data); EG(scope) = old_scope; } else { - long l; + long l; double d; + int varname_len = strlen(ent1->varname); - switch (is_numeric_string(ent1->varname, strlen(ent1->varname), &l, &d, 0)) { + switch (is_numeric_string(ent1->varname, varname_len, &l, &d, 0)) { case IS_DOUBLE: if (d > INT_MAX) { goto bigint; @@ -988,7 +989,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) break; default: bigint: - zend_hash_update(target_hash,ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL); + zend_hash_update(target_hash,ent1->varname, varname_len + 1, &ent1->data, sizeof(zval *), NULL); } } efree(ent1->varname);