]> granicus.if.org Git - php/commitdiff
avoid repeated strlen usage
authorAnatol Belski <ab@php.net>
Thu, 18 Sep 2014 19:28:02 +0000 (21:28 +0200)
committerAnatol Belski <ab@php.net>
Thu, 18 Sep 2014 22:06:30 +0000 (00:06 +0200)
ext/phar/phar_object.c

index c9f31d00f89c9b76c47b71c4cdc65b2e717aaadc..c446dac7dfea8b2bda2ac02389d9bfb9c7b9751e 100755 (executable)
@@ -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]);