1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/soap: various optimisations

* replace strcat/strncpy with memcpy for pre-allocated buffers.
* remove redundant memset before struct copy.
This commit is contained in:
David CARLIER
2026-03-12 17:56:43 +00:00
committed by GitHub
parent 46357cbaaf
commit b0aa6b9626
2 changed files with 2 additions and 11 deletions

View File

@@ -1168,18 +1168,12 @@ try_again:
char *t = ZSTR_VAL(new_uri->path);
char *p = strrchr(t, '/');
if (p) {
zend_string *s = zend_string_alloc((p - t) + ZSTR_LEN(new_uri->path) + 2, 0);
strncpy(ZSTR_VAL(s), t, (p - t) + 1);
ZSTR_VAL(s)[(p - t) + 1] = 0;
strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path));
zend_string *s = zend_string_concat2(t, (p - t) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path));
zend_string_release_ex(new_uri->path, 0);
new_uri->path = s;
}
} else {
zend_string *s = zend_string_alloc(ZSTR_LEN(new_uri->path) + 2, 0);
ZSTR_VAL(s)[0] = '/';
ZSTR_VAL(s)[1] = 0;
strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path));
zend_string *s = zend_string_concat2("/", 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path));
zend_string_release_ex(new_uri->path, 0);
new_uri->path = s;
}

View File

@@ -2433,7 +2433,6 @@ static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashT
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(headers, key, tmp) {
pheader = malloc(sizeof(sdlSoapBindingFunctionHeader));
memset(pheader, 0, sizeof(sdlSoapBindingFunctionHeader));
*pheader = *tmp;
if (pheader->name) {
@@ -2497,7 +2496,6 @@ static HashTable* make_persistent_sdl_parameters(HashTable *params, HashTable *p
ZEND_HASH_FOREACH_STR_KEY_PTR(params, key, tmp) {
pparam = malloc(sizeof(sdlParam));
memset(pparam, 0, sizeof(sdlParam));
*pparam = *tmp;
if (pparam->paramName) {
@@ -2539,7 +2537,6 @@ static HashTable* make_persistent_sdl_function_faults(sdlFunctionPtr func, HashT
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(faults, key, tmp) {
pfault = malloc(sizeof(sdlFault));
memset(pfault, 0, sizeof(sdlFault));
*pfault = *tmp;
if (pfault->name) {