logic: removed shuffling of indexer commands

This commit is contained in:
mlangkabel
2018-08-10 16:10:06 +02:00
parent 337cf2d371
commit 5ace9e080f
3 changed files with 13 additions and 7 deletions
+11 -5
View File
@@ -1,7 +1,6 @@
#include "data/indexer/IndexerCommandList.h"
#include <algorithm>
#include <random>
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
@@ -26,7 +25,7 @@ size_t IndexerCommandList::size() const
return m_commands.size();
}
void IndexerCommandList::shuffle()
void IndexerCommandList::sort()
{
std::lock_guard<std::mutex> lock(m_commandsMutex);
@@ -48,9 +47,16 @@ void IndexerCommandList::shuffle()
if (sourceFileSizesToCommands.size() > 2)
{
srand(unsigned(time(NULL)));
std::random_shuffle(sourceFileSizesToCommands.begin(), sourceFileSizesToCommands.begin() + sourceFileSizesToCommands.size() / 2);
std::random_shuffle(sourceFileSizesToCommands.begin() + sourceFileSizesToCommands.size() / 2, sourceFileSizesToCommands.end());
std::sort(
sourceFileSizesToCommands.begin(),
sourceFileSizesToCommands.begin() + sourceFileSizesToCommands.size() / 2,
[](const PairType& p, const PairType& q) { return p.second->getSourceFilePath().wstr() < q.second->getSourceFilePath().wstr(); }
);
std::sort(
sourceFileSizesToCommands.begin() + sourceFileSizesToCommands.size() / 2,
sourceFileSizesToCommands.end(),
[](const PairType& p, const PairType& q) { return p.second->getSourceFilePath().wstr() < q.second->getSourceFilePath().wstr(); }
);
}
m_commands.clear();
+1 -1
View File
@@ -14,7 +14,7 @@ public:
size_t size() const;
void shuffle();
void sort();
std::shared_ptr<IndexerCommand> consumeCommand();
+1 -1
View File
@@ -468,7 +468,7 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
indexerThreadCount = std::min<int>(indexerThreadCount, indexerCommandList->size());
if (indexerThreadCount > 1)
{
indexerCommandList->shuffle();
indexerCommandList->sort();
}
std::shared_ptr<StorageProvider> storageProvider = std::make_shared<StorageProvider>();