summaryrefslogtreecommitdiff
path: root/src/directoryrefresher.cpp
diff options
context:
space:
mode:
authorRJ <122295667+Liderate@users.noreply.github.com>2025-05-23 03:15:43 -0400
committerGitHub <noreply@github.com>2025-05-23 09:15:43 +0200
commit3ef0db4cca1971ed1552c0314e0039dac792d2e5 (patch)
tree52b3edcbc28326916f2d6800f20b780b54696ae6 /src/directoryrefresher.cpp
parent15f3d2ba0596924c29787938339f1fa3c67135fe (diff)
Speedup refresh when archive parsing is enabled and updateBSAList (#2239)
* Precompute load order for ModThreads * Precompute file infos for plugin association check --------- Co-authored-by: RJ <Liderate@users.noreply.github.com>
Diffstat (limited to 'src/directoryrefresher.cpp')
-rw-r--r--src/directoryrefresher.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp
index e2e05b2c..9afbfca8 100644
--- a/src/directoryrefresher.cpp
+++ b/src/directoryrefresher.cpp
@@ -328,7 +328,8 @@ struct ModThread
int prio = -1;
std::vector<std::wstring> archives;
std::set<std::wstring> enabledArchives;
- DirectoryStats* stats = nullptr;
+ std::vector<std::wstring>* loadOrder = nullptr;
+ DirectoryStats* stats = nullptr;
env::DirectoryWalker walker;
std::condition_variable cv;
@@ -356,18 +357,8 @@ struct ModThread
ds->addFromOrigin(walker, modName, path, prio, *stats);
if (Settings::instance().archiveParsing()) {
- QStringList loadOrder;
- auto gamePlugins = gameFeatures->gameFeature<GamePlugins>();
- if (gamePlugins) {
- loadOrder = gamePlugins->getLoadOrder();
- }
-
- std::vector<std::wstring> lo;
- for (auto&& s : loadOrder) {
- lo.push_back(s.toStdWString());
- }
-
- ds->addFromAllBSAs(modName, path, prio, archives, enabledArchives, lo, *stats);
+ ds->addFromAllBSAs(modName, path, prio, archives, enabledArchives, *loadOrder,
+ *stats);
}
if (progress) {
@@ -400,6 +391,18 @@ void DirectoryRefresher::addMultipleModsFilesToStructure(
log::debug("refresher: using {} threads", m_threadCount);
g_threads.setMax(m_threadCount);
+ std::vector<std::wstring> loadOrder;
+ if (Settings::instance().archiveParsing()) {
+ auto gamePlugins = m_Core.gameFeatures().gameFeature<GamePlugins>();
+ if (gamePlugins) {
+ QStringList lo = gamePlugins->getLoadOrder();
+ loadOrder.reserve(lo.size());
+ for (auto&& s : lo) {
+ loadOrder.push_back(s.toStdWString());
+ }
+ }
+ }
+
for (std::size_t i = 0; i < entries.size(); ++i) {
const auto& e = entries[i];
const int prio = e.priority + 1;
@@ -436,7 +439,8 @@ void DirectoryRefresher::addMultipleModsFilesToStructure(
mt.enabledArchives.insert(a.toStdWString());
}
- mt.stats = &stats[i];
+ mt.loadOrder = &loadOrder;
+ mt.stats = &stats[i];
mt.wakeup();
}