summaryrefslogtreecommitdiff
path: root/Zend/zend_language_scanner.l
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-03-04 02:05:28 +0300
committerDmitry Stogov <dmitry@zend.com>2015-03-04 02:05:28 +0300
commit2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542 (patch)
tree9d9d57215f756c387722e74d7d1e1c2de3276a1c /Zend/zend_language_scanner.l
parent2841aa95db84f3563c94c90f84bf7f47ba159a2d (diff)
downloadphp-git-2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542.tar.gz
Use zend_string* instead of char* for opened_patch handling. Avoid reallocations and improve string reuse.
Diffstat (limited to 'Zend/zend_language_scanner.l')
-rw-r--r--Zend/zend_language_scanner.l14
1 files changed, 6 insertions, 8 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 31c9a52a44..e4b1314f76 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -482,7 +482,6 @@ ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding)
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
{
- const char *file_path = NULL;
char *buf;
size_t size, offset = 0;
zend_string *compiled_filename;
@@ -536,12 +535,11 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
BEGIN(INITIAL);
if (file_handle->opened_path) {
- file_path = file_handle->opened_path;
+ compiled_filename = zend_string_copy(file_handle->opened_path);
} else {
- file_path = file_handle->filename;
+ compiled_filename = zend_string_init(file_handle->filename, strlen(file_handle->filename), 0);
}
- compiled_filename = zend_string_init(file_path, strlen(file_path), 0);
zend_set_compiled_filename(compiled_filename);
zend_string_release(compiled_filename);
@@ -623,7 +621,7 @@ zend_op_array *compile_filename(int type, zval *filename)
zend_file_handle file_handle;
zval tmp;
zend_op_array *retval;
- char *opened_path = NULL;
+ zend_string *opened_path = NULL;
if (Z_TYPE_P(filename) != IS_STRING) {
tmp = *filename;
@@ -640,13 +638,13 @@ zend_op_array *compile_filename(int type, zval *filename)
retval = zend_compile_file(&file_handle, type);
if (retval && file_handle.handle.stream.handle) {
if (!file_handle.opened_path) {
- file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename));
+ file_handle.opened_path = opened_path = zend_string_copy(Z_STR_P(filename));
}
- zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path));
+ zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path);
if (opened_path) {
- efree(opened_path);
+ zend_string_release(opened_path);
}
}
zend_destroy_file_handle(&file_handle);