Improve locality of stream variable

This commit is contained in:
George Peter Banyard 2023-04-05 14:19:36 +01:00
parent 96ffdd492c
commit 06896d1c45

View File

@ -156,7 +156,6 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
zend_string *filename; zend_string *filename;
zend_string *contents; zend_string *contents;
bool use_include_path = 0; bool use_include_path = 0;
php_stream *stream;
zend_long offset = -1; zend_long offset = -1;
zend_long maxlen; zend_long maxlen;
bool maxlen_is_null = 1; bool maxlen_is_null = 1;
@ -190,6 +189,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
} }
php_stream_context *context = NULL; php_stream_context *context = NULL;
php_stream *stream;
if (zcontext) { if (zcontext) {
context = php_stream_context_from_zval(zcontext, 0); context = php_stream_context_from_zval(zcontext, 0);
} }
@ -232,7 +233,6 @@ PHAR_FUNC(phar_readfile) /* {{{ */
zend_string *filename; zend_string *filename;
bool use_include_path = 0; bool use_include_path = 0;
zval *zcontext = NULL; zval *zcontext = NULL;
php_stream *stream;
if (!PHAR_G(intercepted)) { if (!PHAR_G(intercepted)) {
goto skip_phar; goto skip_phar;
@ -251,7 +251,9 @@ PHAR_FUNC(phar_readfile) /* {{{ */
goto skip_phar; goto skip_phar;
} }
php_stream_context *context = php_stream_context_from_zval(zcontext, 0);; php_stream *stream;
php_stream_context *context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(ZSTR_VAL(name), "rb", 0 | REPORT_ERRORS, NULL, context); stream = php_stream_open_wrapper_ex(ZSTR_VAL(name), "rb", 0 | REPORT_ERRORS, NULL, context);
zend_string_release_ex(name, false); zend_string_release_ex(name, false);
@ -277,7 +279,6 @@ PHAR_FUNC(phar_fopen) /* {{{ */
size_t mode_len; size_t mode_len;
bool use_include_path = 0; bool use_include_path = 0;
zval *zcontext = NULL; zval *zcontext = NULL;
php_stream *stream;
if (!PHAR_G(intercepted)) { if (!PHAR_G(intercepted)) {
goto skip_phar; goto skip_phar;
@ -297,7 +298,9 @@ PHAR_FUNC(phar_fopen) /* {{{ */
goto skip_phar; goto skip_phar;
} }
php_stream *stream;
php_stream_context *context = php_stream_context_from_zval(zcontext, 0); php_stream_context *context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(ZSTR_VAL(name), mode, 0 | REPORT_ERRORS, NULL, context); stream = php_stream_open_wrapper_ex(ZSTR_VAL(name), mode, 0 | REPORT_ERRORS, NULL, context);
zend_string_release_ex(name, false); zend_string_release_ex(name, false);