]> granicus.if.org Git - php/commitdiff
avoid repeated strlen() usage
authorAnatol Belski <ab@php.net>
Sun, 14 Sep 2014 10:59:31 +0000 (12:59 +0200)
committerAnatol Belski <ab@php.net>
Sun, 14 Sep 2014 10:59:31 +0000 (12:59 +0200)
ext/zip/php_zip.c

index 5f98a639e125c12f5587129c0e8d3847d03d94c6..0f6a6bfe88f41c15bcb89a088433ad62fdb71577 100644 (file)
@@ -1609,9 +1609,11 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
                RETURN_FALSE;
        }
 
-       if (remove_path && remove_path_len > 1 && (remove_path[strlen(remove_path) - 1] == '/' ||
-               remove_path[strlen(remove_path) - 1] == '\\')) {
-               remove_path[strlen(remove_path) - 1] = '\0';
+       if (remove_path && remove_path_len > 1) {
+               int tmp_idx = (int)strlen(remove_path) - 1;
+               if (remove_path[tmp_idx] == '/' || remove_path[tmp_idx] == '\\') {
+                       remove_path[tmp_idx] = '\0';
+               }
        }
 
        if (type == 1) {