forked from qt-creator/qt-creator
Clang: Add file cache
The database is using file path integer ids to handle file paths because otherwise we would save many redundant data. This patch is improving it further with the introduction of a database based file path cache. The entries are now divided in a directory path and file name. This is quite handy for directory based file watching. Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -63,22 +63,27 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
FilePath(const Utils::PathString &directory, const Utils::PathString &name)
|
||||
: m_path({std::move(directory), "/", std::move(name)}),
|
||||
FilePath(Utils::SmallStringView directory, Utils::SmallStringView name)
|
||||
: m_path({directory, "/", name}),
|
||||
m_slashIndex(directory.size())
|
||||
{}
|
||||
|
||||
Utils::SmallStringView directory() const
|
||||
Utils::SmallStringView directory() const noexcept
|
||||
{
|
||||
return m_path.mid(0, m_slashIndex);
|
||||
}
|
||||
|
||||
Utils::SmallStringView name() const
|
||||
Utils::SmallStringView name() const noexcept
|
||||
{
|
||||
return m_path.mid(m_slashIndex + 1, m_path.size() - m_slashIndex - 1);
|
||||
}
|
||||
|
||||
const Utils::PathString &path() const
|
||||
const Utils::PathString &path() const noexcept
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
operator Utils::PathString() const noexcept
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
@@ -105,9 +110,7 @@ public:
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &out, const FilePath &filePath)
|
||||
{
|
||||
out << filePath.directory() << "/" << filePath.name();
|
||||
|
||||
return out;
|
||||
return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")";
|
||||
}
|
||||
|
||||
friend bool operator==(const FilePath &first, const FilePath &second)
|
||||
@@ -115,6 +118,16 @@ public:
|
||||
return first.m_path == second.m_path;
|
||||
}
|
||||
|
||||
friend bool operator==(const FilePath &first, const Utils::SmallStringView &second)
|
||||
{
|
||||
return first.path() == second;
|
||||
}
|
||||
|
||||
friend bool operator==(const Utils::SmallStringView &first, const FilePath&second)
|
||||
{
|
||||
return second == first;
|
||||
}
|
||||
|
||||
friend bool operator<(const FilePath &first, const FilePath &second)
|
||||
{
|
||||
return first.m_path < second.m_path;
|
||||
@@ -125,11 +138,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::size_t slashIndex() const
|
||||
{
|
||||
return m_slashIndex;
|
||||
}
|
||||
|
||||
private:
|
||||
Utils::PathString m_path = "/";
|
||||
std::size_t m_slashIndex = 0;
|
||||
};
|
||||
|
||||
using FilePaths = std::vector<FilePath>;
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const FilePath &filePath);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Reference in New Issue
Block a user