From c499da93646120f2db783207901c65e41ce9864d Mon Sep 17 00:00:00 2001 From: Tsarevich Dmitry Date: Sun, 23 Feb 2020 18:08:21 +0300 Subject: [PATCH] [perf] Optimize check for zero length string strlen has O(n) complexity, checking for first string char is '\0' just O(1). --- src/iso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iso.c b/src/iso.c index 5d1dc0b5..09eabc29 100644 --- a/src/iso.c +++ b/src/iso.c @@ -445,7 +445,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha while ((p_udf_dirent = udf_readdir(p_udf_dirent)) != NULL) { if (FormatStatus) goto out; psz_basename = udf_get_filename(p_udf_dirent); - if (strlen(psz_basename) == 0) + if (psz_basename[0] == '\0') continue; length = (int)(3 + strlen(psz_path) + strlen(psz_basename) + strlen(psz_extract_dir) + 24); psz_fullpath = (char*)calloc(sizeof(char), length);