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:
@@ -145,25 +145,7 @@ public:
|
||||
BasicSmallString(std::initializer_list<Utils::SmallStringView> list)
|
||||
: m_data(Internal::StringDataLayout<Size>())
|
||||
{
|
||||
std::size_t size = std::accumulate(list.begin(),
|
||||
list.end(),
|
||||
std::size_t(0),
|
||||
[] (std::size_t size, Utils::SmallStringView string) {
|
||||
return size + string.size();
|
||||
});
|
||||
|
||||
reserve(size);
|
||||
setSize(size);
|
||||
|
||||
char *currentData = data();
|
||||
|
||||
for (Utils::SmallStringView string : list) {
|
||||
std::memcpy(currentData, string.data(), string.size());
|
||||
|
||||
currentData += string.size();
|
||||
}
|
||||
|
||||
at(size) = 0;
|
||||
appendInitializerList(list, 0);
|
||||
}
|
||||
|
||||
~BasicSmallString() noexcept
|
||||
@@ -478,6 +460,13 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
BasicSmallString &operator+=(std::initializer_list<SmallStringView> list)
|
||||
{
|
||||
appendInitializerList(list, size());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void replace(SmallStringView fromText, SmallStringView toText)
|
||||
{
|
||||
if (toText.size() == fromText.size())
|
||||
@@ -690,6 +679,27 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
void appendInitializerList(std::initializer_list<SmallStringView> list, std::size_t initialSize)
|
||||
{
|
||||
auto addSize = [] (std::size_t size, Utils::SmallStringView string) {
|
||||
return size + string.size();
|
||||
};
|
||||
|
||||
std::size_t size = std::accumulate(list.begin(), list.end(), initialSize, addSize);
|
||||
|
||||
reserve(size);
|
||||
setSize(size);
|
||||
|
||||
char *currentData = data() + initialSize;
|
||||
|
||||
for (Utils::SmallStringView string : list) {
|
||||
std::memcpy(currentData, string.data(), string.size());
|
||||
currentData += string.size();
|
||||
}
|
||||
|
||||
at(size) = 0;
|
||||
}
|
||||
|
||||
void initializeLongString(size_type size, size_type capacity)
|
||||
{
|
||||
m_data.allocated.data.pointer[size] = 0;
|
||||
|
||||
Reference in New Issue
Block a user