]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
do not add invocation of UTIL_isRegularFile() 3584/head
authorYann Collet <cyan@fb.com>
Fri, 31 Mar 2023 20:09:52 +0000 (13:09 -0700)
committerYann Collet <cyan@fb.com>
Fri, 31 Mar 2023 20:09:52 +0000 (13:09 -0700)
programs/fileio.c

index 877460302b603ffe02135fd670ee27c494780b73..4f75ff4748a20dc4b6d8f8e07cd411e19a24607f 100644 (file)
@@ -581,6 +581,8 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
                 const char* srcFileName, const char* dstFileName,
                 const int mode)
 {
+    int isDstRegFile;
+
     if (prefs->testMode) return NULL;  /* do not open file in test mode */
 
     assert(dstFileName != NULL);
@@ -600,15 +602,16 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
         return NULL;
     }
 
+    isDstRegFile = UTIL_isRegularFile(dstFileName);  /* invoke once */
     if (prefs->sparseFileSupport == 1) {
-        if (!UTIL_isRegularFile(dstFileName)) {
+        if (!isDstRegFile) {
             prefs->sparseFileSupport = 0;
             DISPLAYLEVEL(4, "Sparse File Support is disabled when output is not a file \n");
         }
         prefs->sparseFileSupport = ZSTD_SPARSE_DEFAULT;
     }
 
-    if (UTIL_isRegularFile(dstFileName)) {
+    if (isDstRegFile) {
         /* Check if destination file already exists */
 #if !defined(_WIN32)
         /* this test does not work on Windows :