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);
|
||||
|
||||
return compareEntries(sourceEntries) && notReseted(sourceEntries);
|
||||
return compareEntries(sourceEntries);
|
||||
}
|
||||
|
||||
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:
|
||||
bool compareEntries(const SourceEntries &sourceEntries) const
|
||||
{
|
||||
@@ -118,33 +104,13 @@ private:
|
||||
m_fileSystem.lastModified(
|
||||
sourceEntry.sourceId));
|
||||
}),
|
||||
[](auto first, auto second) {
|
||||
return first.sourceId < second.sourceId && first.timeStamp > 0;
|
||||
});
|
||||
[](auto first, auto second) { return first.sourceId < second.sourceId; });
|
||||
|
||||
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:
|
||||
mutable SourceTimeStamps m_currentSourceTimeStamps;
|
||||
mutable FilePathIds m_resetFilePathIds;
|
||||
FileSystemInterface &m_fileSystem;
|
||||
};
|
||||
|
||||
|
@@ -131,63 +131,4 @@ TEST_F(ModifiedTimeChecker, IsNotUpToDateAnyMoreAfterUpdating)
|
||||
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
|
||||
|
Reference in New Issue
Block a user