forked from qt-creator/qt-creator
Clang: Remove reset from ModifiedTimeChecker
Change-Id: I8eb7258e929ad851310b3dfae818152eed88960e Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
updateCurrentSourceTimeStamps(sourceEntries);
|
updateCurrentSourceTimeStamps(sourceEntries);
|
||||||
|
|
||||||
return compareEntries(sourceEntries) && notReseted(sourceEntries);
|
return compareEntries(sourceEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pathsChanged(const FilePathIds &filePathIds) override
|
void pathsChanged(const FilePathIds &filePathIds) override
|
||||||
@@ -66,20 +66,6 @@ public:
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(const FilePathIds &filePathIds)
|
|
||||||
{
|
|
||||||
FilePathIds newResetFilePathIds;
|
|
||||||
newResetFilePathIds.reserve(newResetFilePathIds.size() + m_resetFilePathIds.size());
|
|
||||||
|
|
||||||
std::set_union(m_resetFilePathIds.begin(),
|
|
||||||
m_resetFilePathIds.end(),
|
|
||||||
filePathIds.begin(),
|
|
||||||
filePathIds.end(),
|
|
||||||
std::back_inserter(newResetFilePathIds));
|
|
||||||
|
|
||||||
m_resetFilePathIds = std::move(newResetFilePathIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool compareEntries(const SourceEntries &sourceEntries) const
|
bool compareEntries(const SourceEntries &sourceEntries) const
|
||||||
{
|
{
|
||||||
@@ -118,33 +104,13 @@ private:
|
|||||||
m_fileSystem.lastModified(
|
m_fileSystem.lastModified(
|
||||||
sourceEntry.sourceId));
|
sourceEntry.sourceId));
|
||||||
}),
|
}),
|
||||||
[](auto first, auto second) {
|
[](auto first, auto second) { return first.sourceId < second.sourceId; });
|
||||||
return first.sourceId < second.sourceId && first.timeStamp > 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
return newTimeStamps;
|
return newTimeStamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notReseted(const SourceEntries &sourceEntries) const
|
|
||||||
{
|
|
||||||
auto oldSize = m_resetFilePathIds.size();
|
|
||||||
FilePathIds newResetFilePathIds;
|
|
||||||
newResetFilePathIds.reserve(newResetFilePathIds.size());
|
|
||||||
|
|
||||||
std::set_difference(m_resetFilePathIds.begin(),
|
|
||||||
m_resetFilePathIds.end(),
|
|
||||||
sourceEntries.begin(),
|
|
||||||
sourceEntries.end(),
|
|
||||||
std::back_inserter(newResetFilePathIds));
|
|
||||||
|
|
||||||
m_resetFilePathIds = std::move(newResetFilePathIds);
|
|
||||||
|
|
||||||
return oldSize == m_resetFilePathIds.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable SourceTimeStamps m_currentSourceTimeStamps;
|
mutable SourceTimeStamps m_currentSourceTimeStamps;
|
||||||
mutable FilePathIds m_resetFilePathIds;
|
|
||||||
FileSystemInterface &m_fileSystem;
|
FileSystemInterface &m_fileSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -131,63 +131,4 @@ TEST_F(ModifiedTimeChecker, IsNotUpToDateAnyMoreAfterUpdating)
|
|||||||
ASSERT_FALSE(checker.isUpToDate(upToDateEntries));
|
ASSERT_FALSE(checker.isUpToDate(upToDateEntries));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, Reset)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
|
|
||||||
checker.reset({2, 3});
|
|
||||||
|
|
||||||
ASSERT_FALSE(checker.isUpToDate(upToDateEntries));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, UpdateNonResetedId)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
|
|
||||||
checker.reset({2, 3});
|
|
||||||
|
|
||||||
ASSERT_TRUE(checker.isUpToDate({upToDateEntries[0]}));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, ResetTwoTimes)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
checker.reset({2, 3});
|
|
||||||
|
|
||||||
checker.reset({2, 3});
|
|
||||||
|
|
||||||
ASSERT_FALSE(checker.isUpToDate(upToDateEntries));
|
|
||||||
ASSERT_TRUE(checker.isUpToDate(upToDateEntries));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, ResetSecondUpdate)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
checker.reset({2, 3});
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
|
|
||||||
auto isUpToDate = checker.isUpToDate(upToDateEntries);
|
|
||||||
|
|
||||||
ASSERT_TRUE(isUpToDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, ResetPartialUpdate)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
checker.reset({2, 3});
|
|
||||||
checker.isUpToDate({upToDateEntries[1]});
|
|
||||||
|
|
||||||
ASSERT_FALSE(checker.isUpToDate({upToDateEntries[2]}));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ModifiedTimeChecker, ResetMoreIds)
|
|
||||||
{
|
|
||||||
checker.isUpToDate(upToDateEntries);
|
|
||||||
checker.reset({2, 3});
|
|
||||||
|
|
||||||
checker.reset({1, 5});
|
|
||||||
|
|
||||||
ASSERT_FALSE(checker.isUpToDate({upToDateEntries[2]}));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user