From e3d3533f1714a77ece6c891a1269bce3cdadd479 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 1 Mar 2026 22:39:21 +0100 Subject: [PATCH 1/3] fixed #14547 - store absolute path in `FileWithDetails` (fixes slow start-up with a lot of input files) --- cli/cmdlineparser.cpp | 4 ++-- lib/filesettings.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index c017e238409..671739b5a83 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -269,10 +269,10 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) { auto it = filesResolved.begin(); while (it != filesResolved.end()) { - const std::string& absname = Path::getAbsoluteFilePath(it->spath()); + const std::string& absname = it->abspath(); // TODO: log if duplicated files were dropped filesResolved.erase(std::remove_if(std::next(it), filesResolved.end(), [&](const FileWithDetails& entry) { - return Path::getAbsoluteFilePath(entry.spath()) == absname; + return entry.abspath() == absname; }), filesResolved.end()); ++it; } diff --git a/lib/filesettings.h b/lib/filesettings.h index b51f092d6b4..e6b8216449c 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -50,6 +50,7 @@ class FileWithDetails { mPath = std::move(path); mPathSimplified = Path::simplifyPath(mPath); + mPathAbsolute = Path::getAbsoluteFilePath(mPath); } const std::string& path() const @@ -62,6 +63,11 @@ class FileWithDetails return mPathSimplified; } + const std::string& abspath() const + { + return mPathAbsolute; + } + std::size_t size() const { return mSize; @@ -89,6 +95,7 @@ class FileWithDetails private: std::string mPath; std::string mPathSimplified; + std::string mPathAbsolute; Standards::Language mLang = Standards::Language::None; std::size_t mSize; std::size_t mFsFileId{0}; From 3ccfb5c4638e88ab7a53fe09931e3f96af9fe170 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 1 Mar 2026 22:48:35 +0100 Subject: [PATCH 2/3] FileWithDetails: delay resolution of absolute path until usage --- lib/filesettings.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/filesettings.h b/lib/filesettings.h index e6b8216449c..aaa2f28779a 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -50,7 +50,7 @@ class FileWithDetails { mPath = std::move(path); mPathSimplified = Path::simplifyPath(mPath); - mPathAbsolute = Path::getAbsoluteFilePath(mPath); + mPathAbsolute.clear(); } const std::string& path() const @@ -65,6 +65,9 @@ class FileWithDetails const std::string& abspath() const { + // use delayed resolution as it will fail for files which do not exist + if (mPathAbsolute.empty()) + mPathAbsolute = Path::getAbsoluteFilePath(mPath); return mPathAbsolute; } @@ -95,7 +98,7 @@ class FileWithDetails private: std::string mPath; std::string mPathSimplified; - std::string mPathAbsolute; + mutable std::string mPathAbsolute; Standards::Language mLang = Standards::Language::None; std::size_t mSize; std::size_t mFsFileId{0}; From edf1059fa2d3e4f0d641f05109201195e261f815 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 1 Mar 2026 22:51:49 +0100 Subject: [PATCH 3/3] CmdLineParser: filter out files before running de-duplication in `fillSettingsFromArgs()` --- cli/cmdlineparser.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 671739b5a83..e5c990ab494 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -206,8 +206,6 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty())); if (!fileSettingsRef.empty()) { - // TODO: de-duplicate - std::list fileSettings; if (!mSettings.fileFilters.empty()) { // filter only for the selected filenames from all project files @@ -225,6 +223,8 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) fileSettings = fileSettingsRef; } + // TODO: de-duplicate + mFileSettings.clear(); frontend::applyLang(fileSettings, mSettings, mEnforcedLang); @@ -265,19 +265,6 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) return false; } - // de-duplicate files - { - auto it = filesResolved.begin(); - while (it != filesResolved.end()) { - const std::string& absname = it->abspath(); - // TODO: log if duplicated files were dropped - filesResolved.erase(std::remove_if(std::next(it), filesResolved.end(), [&](const FileWithDetails& entry) { - return entry.abspath() == absname; - }), filesResolved.end()); - ++it; - } - } - std::list files; if (!mSettings.fileFilters.empty()) { files = filterFiles(mSettings.fileFilters, filesResolved); @@ -291,6 +278,19 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) files = std::move(filesResolved); } + // de-duplicate files + { + auto it = files.begin(); + while (it != files.end()) { + const std::string& absname = it->abspath(); + // TODO: log if duplicated files were dropped + files.erase(std::remove_if(std::next(it), files.end(), [&](const FileWithDetails& entry) { + return entry.abspath() == absname; + }), files.end()); + ++it; + } + } + frontend::applyLang(files, mSettings, mEnforcedLang); // sort the markup last