Skip to content

Commit 32f0d24

Browse files
committed
soap: Get decompression function directly from function table and call it
The code is already looking up the entry in the function table anyway, so might as well use it directly. This simplifies the code and avoids a redundant lookup.
1 parent 5683708 commit 32f0d24

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

ext/soap/php_http.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,20 +1294,18 @@ int make_http_soap_request(zval *this_ptr,
12941294
/* Decompress response */
12951295
content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding:");
12961296
if (content_encoding) {
1297-
zval func;
12981297
zval retval;
12991298
zval params[1];
1299+
zend_function *decompression_fn;
13001300

13011301
/* Warning: the zlib function names are chosen in an unfortunate manner.
13021302
* Check zlib.c to see how a function corresponds with a particular format. */
13031303
if ((strcmp(content_encoding,"gzip") == 0 ||
13041304
strcmp(content_encoding,"x-gzip") == 0) &&
1305-
zend_hash_str_exists(EG(function_table), "gzdecode", sizeof("gzdecode")-1)) {
1306-
ZVAL_STRING(&func, "gzdecode");
1305+
(decompression_fn = zend_hash_str_find_ptr(EG(function_table), "gzdecode", sizeof("gzdecode")-1))) {
13071306
ZVAL_STR_COPY(&params[0], http_body);
13081307
} else if (strcmp(content_encoding,"deflate") == 0 &&
1309-
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1310-
ZVAL_STRING(&func, "gzuncompress");
1308+
(decompression_fn = zend_hash_str_find_ptr(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1))) {
13111309
ZVAL_STR_COPY(&params[0], http_body);
13121310
} else {
13131311
efree(content_encoding);
@@ -1319,15 +1317,13 @@ int make_http_soap_request(zval *this_ptr,
13191317
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL, SOAP_GLOBAL(lang_en));
13201318
return FALSE;
13211319
}
1322-
if (call_user_function(CG(function_table), (zval*)NULL, &func, &retval, 1, params) == SUCCESS &&
1323-
Z_TYPE(retval) == IS_STRING) {
1320+
zend_call_known_function(decompression_fn, NULL, NULL, &retval, 1, params, NULL);
1321+
if (Z_TYPE(retval) == IS_STRING) {
13241322
zval_ptr_dtor(&params[0]);
1325-
zval_ptr_dtor(&func);
13261323
zend_string_release_ex(http_body, 0);
13271324
ZVAL_COPY_VALUE(return_value, &retval);
13281325
} else {
13291326
zval_ptr_dtor(&params[0]);
1330-
zval_ptr_dtor(&func);
13311327
zval_ptr_dtor(&retval);
13321328
efree(content_encoding);
13331329
zend_string_release_ex(http_headers, 0);

0 commit comments

Comments
 (0)