From: Anatol Belski Date: Sun, 14 Sep 2014 10:59:31 +0000 (+0200) Subject: avoid repeated strlen() usage X-Git-Tag: PRE_NATIVE_TLS_MERGE~158^2~85^2~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6b376efe538997369efc3dfffede295f433105d;p=php avoid repeated strlen() usage --- diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 5f98a639e1..0f6a6bfe88 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -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) {