logic: randomize source file parsing order to reduce header file double parsing
saves 20% parsing time for Coati
This commit is contained in:
@@ -138,18 +138,16 @@ bool FileRegister::includeFileIsParsed(const FilePath& filePath) const
|
|||||||
|
|
||||||
FilePath FileRegister::consumeSourceFile()
|
FilePath FileRegister::consumeSourceFile()
|
||||||
{
|
{
|
||||||
|
std::vector<FilePath> paths = getUnparsedSourceFilePaths();
|
||||||
|
|
||||||
FilePath path;
|
FilePath path;
|
||||||
|
|
||||||
|
if (paths.size())
|
||||||
{
|
{
|
||||||
|
path = paths[rand() % paths.size()];
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
||||||
for (std::map<FilePath, ParseState>::iterator it = m_sourceFilePaths.begin(); it != m_sourceFilePaths.end(); it++)
|
m_sourceFilePaths[path] = STATE_PARSING;
|
||||||
{
|
|
||||||
if (it->second == STATE_UNPARSED)
|
|
||||||
{
|
|
||||||
it->second = STATE_PARSING;
|
|
||||||
path = it->first;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user