com php-src: Avoid repeatable calls to strstr(): ext/opcache/ZendAccelerator.c ext/opcache/ZendAccelerator.h
| From: | Dmitry Stogov | Date: | Mon, 09 Feb 2015 19:42:37 +0000 |
| Subject: | com php-src: Avoid repeatable calls to strstr(): ext/opcache/ZendAccelerator.c ext/opcache/ZendAccelerator.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84753@lists.php.net to get a copy of this message | ||
Commit: 9d5d736869d26268d3bbf6dee1990728deda10c8
Author: Dmitry Stogov <dmitry@zend.com> Mon, 9 Feb 2015 22:42:37 +0300
Parents: 09a3e7377a30cad769b5c92254e101a32ab77731
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9d5d736869d26268d3bbf6dee1990728deda10c8
Log:
Avoid repeatable calls to strstr()
Changed paths:
M ext/opcache/ZendAccelerator.c
M ext/opcache/ZendAccelerator.h
Diff:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 0bf0bed..ebe7942 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -1173,6 +1173,11 @@ static zend_persistent_script
*cache_script_in_shared_memory(zend_persistent_scr
/* Copy into shared memory */
new_persistent_script = zend_accel_script_persist(new_persistent_script, &key, key_length);
+ new_persistent_script->is_phar =
+ new_persistent_script->full_path &&
+ strstr(new_persistent_script->full_path->val, ".phar") &&
+ !strstr(new_persistent_script->full_path->val, "://");
+
/* Consistency check */
if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) {
zend_accel_error(
@@ -1634,7 +1639,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
type)
EG(current_execute_data)->opline->extended_value != ZEND_REQUIRE_ONCE)) {
if (zend_hash_add_empty_element(&EG(included_files), persistent_script->full_path) !=
NULL) {
/* ext/phar has to load phar's metadata into memory */
- if (strstr(persistent_script->full_path->val, ".phar") &&
!strstr(persistent_script->full_path->val, "://")) {
+ if (persistent_script->is_phar) {
php_stream_statbuf ssb;
char *fname = emalloc(sizeof("phar://") + persistent_script->full_path->len);
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index d08a641..369f609 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -161,6 +161,7 @@ typedef struct _zend_persistent_script {
int ping_auto_globals_mask; /* which autoglobals are used by the script */
accel_time_t timestamp; /* the script modification time */
zend_bool corrupted;
+ zend_bool is_phar;
void *mem; /* shared memory area used by script structures */
size_t size; /* size of used shared memory */