From abac966eec71a2f3af83ae6c4f9a8947cdcd02b4 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Fri, 6 Dec 2024 13:15:08 -0800
Subject: [PATCH] Optimize mkpath()

If the path already exists (is a directory), don't need to check each path
element for existence.

This should help with the speed of saving of large file.ini (Nelgin's) when a
lot of directories have "Check for File Existence" set to "Yes".
---
 src/xpdev/dirwrap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index 7ea60a4501..28c3c6afea 100644
--- a/src/xpdev/dirwrap.c
+++ b/src/xpdev/dirwrap.c
@@ -1214,6 +1214,9 @@ int mkpath(const char* path)
 	char	dir[MAX_PATH+1];
 	int		result=0;
 
+	if(isdir(path))
+		return 0;
+
 #ifdef _WIN32
 	if(p[1]==':')	/* Skip drive letter, if specified */
 		p+=2;
-- 
GitLab