com php-src: avoid repeated strlen usage: ext/phar/phar_objec t.c
| From: | Anatol Belski | Date: | Thu, 18 Sep 2014 22:06:30 +0000 |
| Subject: | com php-src: avoid repeated strlen usage: ext/phar/phar_objec t.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81751@lists.php.net to get a copy of this message | ||
Commit: 6beb91c202495fea23534a5bfba58dd12a290152
Author: Anatol Belski <ab@php.net> Thu, 18 Sep 2014 21:28:02 +0200
Parents: 8a9dd4a1d75a9b8929914c383ef55dec2c455551
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6beb91c202495fea23534a5bfba58dd12a290152
Log:
avoid repeated strlen usage
Changed paths:
M ext/phar/phar_object.c
Diff:
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index c9f31d0..c446dac 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -553,6 +553,7 @@ PHP_METHOD(Phar, webPhar)
int entry_len, code, not_cgi;
phar_archive_data *phar = NULL;
phar_entry_info *info = NULL;
+ size_t sapi_mod_name_len = strlen(sapi_module.name);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!saz", &alias,
&alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride,
&rewrite) == FAILURE) {
return;
@@ -587,9 +588,9 @@ PHP_METHOD(Phar, webPhar)
++basename;
}
- if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 &&
!strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1))
- || (strlen(sapi_module.name) == sizeof("fpm-fcgi")-1 &&
!strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi")-1))
- || (strlen(sapi_module.name) == sizeof("cgi")-1 && !strncmp(sapi_module.name,
"cgi", sizeof("cgi")-1))) {
+ if ((sapi_mod_name_len == sizeof("cgi-fcgi") - 1 && !strncmp(sapi_module.name,
"cgi-fcgi", sizeof("cgi-fcgi") - 1))
+ || (sapi_mod_name_len == sizeof("fpm-fcgi") - 1 && !strncmp(sapi_module.name,
"fpm-fcgi", sizeof("fpm-fcgi") - 1))
+ || (sapi_mod_name_len == sizeof("cgi") - 1 && !strncmp(sapi_module.name,
"cgi", sizeof("cgi") - 1))) {
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) {
HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);