Skip to content

Commit a055e93

Browse files
author
Ilia Alshanetsky
committed
optimize out strlen() calls
# Patch by Matt Wilmas
1 parent 1c4806c commit a055e93

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ext/standard/basic_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,13 +4665,13 @@ PHP_FUNCTION(getopt)
46654665
}
46664666
} else {
46674667
/* other strings */
4668-
if(zend_hash_find(HASH_OF(return_value), optname, strlen(optname)+1, (void **)&args) != FAILURE) {
4668+
if(zend_hash_find(HASH_OF(return_value), optname, optname_len + 1, (void **)&args) != FAILURE) {
46694669
if(Z_TYPE_PP(args) != IS_ARRAY) {
46704670
convert_to_array_ex(args);
46714671
}
46724672
zend_hash_next_index_insert(HASH_OF(*args), (void *)&val, sizeof(zval *), NULL);
46734673
} else {
4674-
zend_hash_add(HASH_OF(return_value), optname, strlen(optname)+1, (void *)&val, sizeof(zval *), NULL);
4674+
zend_hash_add(HASH_OF(return_value), optname, optname_len + 1, (void *)&val, sizeof(zval *), NULL);
46754675
}
46764676
}
46774677
}

ext/wddx/wddx.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,11 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
974974
add_property_zval(ent2->data, ent1->varname, ent1->data);
975975
EG(scope) = old_scope;
976976
} else {
977-
long l;
977+
long l;
978978
double d;
979+
int varname_len = strlen(ent1->varname);
979980

980-
switch (is_numeric_string(ent1->varname, strlen(ent1->varname), &l, &d, 0)) {
981+
switch (is_numeric_string(ent1->varname, varname_len, &l, &d, 0)) {
981982
case IS_DOUBLE:
982983
if (d > INT_MAX) {
983984
goto bigint;
@@ -988,7 +989,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
988989
break;
989990
default:
990991
bigint:
991-
zend_hash_update(target_hash,ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
992+
zend_hash_update(target_hash,ent1->varname, varname_len + 1, &ent1->data, sizeof(zval *), NULL);
992993
}
993994
}
994995
efree(ent1->varname);

0 commit comments

Comments
 (0)