Skip to content

Commit

Permalink
optimize out strlen() calls
Browse files Browse the repository at this point in the history
# Patch by Matt Wilmas
  • Loading branch information
Ilia Alshanetsky committed Dec 13, 2006
1 parent 1c4806c commit a055e93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions ext/wddx/wddx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit a055e93

Please sign in to comment.