From: Anatol Belski Date: Thu, 18 Sep 2014 19:28:02 +0000 (+0200) Subject: avoid repeated strlen usage X-Git-Tag: POST_NATIVE_TLS_MERGE^2~213 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6beb91c202495fea23534a5bfba58dd12a290152;p=php avoid repeated strlen usage --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index c9f31d00f8..c446dac7df 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]);