From 14a9eeb5a07e5ad4910e3cce75d312548733ee64 Mon Sep 17 00:00:00 2001 From: Jackson Sun Date: Wed, 10 Dec 2025 02:27:13 -0500 Subject: [PATCH] Speedup to detect the existence of files on Windows Signed-off-by: Jackson Sun --- src/libutil/filesystem.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libutil/filesystem.cpp b/src/libutil/filesystem.cpp index 8c0fccadc8..504cbd8480 100644 --- a/src/libutil/filesystem.cpp +++ b/src/libutil/filesystem.cpp @@ -330,8 +330,15 @@ Filesystem::path_is_absolute(string_view path, bool dot_is_absolute) bool Filesystem::exists(string_view path) noexcept { +#ifdef _WIN32 + // filesystem::exists is slow on Windows for network paths, so use the + // WinAPI directly + return INVALID_FILE_ATTRIBUTES + != GetFileAttributesW(Strutil::utf8_to_utf16wstring(path).c_str()); +#else error_code ec; return filesystem::exists(u8path(path), ec); +#endif }