diff options
author | Eike Ziller <[email protected]> | 2018-11-09 13:30:40 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2018-11-09 13:30:40 +0100 |
commit | 3666e3aaeb26f91097a473491ea4cf58219029ca (patch) | |
tree | 2d1387557e243eacfe78698371c7726aa9a19350 /src/libs | |
parent | 951eb885af8692c2c4aac67d18e3cbf033b7e912 (diff) | |
parent | dc82e49b62d6b851900689321828aee95f8eab54 (diff) |
Merge remote-tracking branch 'origin/4.8'
Conflicts:
tests/unit/unittest/unittest.pro
Change-Id: I4f0ab05f96ee60900a3a35fad4c7331238367593
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/clangsupport/filepathcache.h | 22 | ||||
-rw-r--r-- | src/libs/clangsupport/filepathid.cpp | 2 | ||||
-rw-r--r-- | src/libs/clangsupport/filepathid.h | 17 | ||||
-rw-r--r-- | src/libs/clangsupport/filepathstorage.h | 8 | ||||
-rw-r--r-- | src/libs/clangsupport/filepathstoragesources.h | 11 | ||||
-rw-r--r-- | src/libs/clangsupport/filepathstoragesqlitestatementfactory.h | 4 | ||||
-rw-r--r-- | src/libs/clangsupport/refactoringdatabaseinitializer.h | 3 |
7 files changed, 36 insertions, 31 deletions
diff --git a/src/libs/clangsupport/filepathcache.h b/src/libs/clangsupport/filepathcache.h index d0c8a529dff..bdd925a79c8 100644 --- a/src/libs/clangsupport/filepathcache.h +++ b/src/libs/clangsupport/filepathcache.h @@ -133,7 +133,7 @@ public: return m_filePathStorage.fetchSourceId(directoryId, fileName); }); - return {directoryId, fileNameId}; + return fileNameId; } FilePath filePath(FilePathId filePathId) const @@ -141,20 +141,20 @@ public: if (Q_UNLIKELY(!filePathId.isValid())) throw NoFilePathForInvalidFilePathId(); - auto fetchFilePath = [&] (int id) { return m_filePathStorage.fetchDirectoryPath(id); }; - - Utils::PathString directoryPath = m_directoryPathCache.string(filePathId.directoryId, - fetchFilePath); + auto fetchSoureNameAndDirectoryId = [&] (int id) { + auto entry = m_filePathStorage.fetchSourceNameAndDirectoryId(id); + return FileNameEntry{entry.sourceName, entry.directoryId}; + }; + FileNameEntry entry = m_fileNameCache.string(filePathId.filePathId, + fetchSoureNameAndDirectoryId); - auto fetchSoureName = [&] (int id) { - return FileNameEntry{m_filePathStorage.fetchSourceName(id), filePathId.directoryId}; - }; + auto fetchDirectoryPath = [&] (int id) { return m_filePathStorage.fetchDirectoryPath(id); }; - Utils::SmallString fileName = m_fileNameCache.string(filePathId.filePathId, - fetchSoureName); + Utils::PathString directoryPath = m_directoryPathCache.string(entry.directoryId, + fetchDirectoryPath); - return FilePath{directoryPath, fileName}; + return FilePath{directoryPath, entry.fileName}; } private: diff --git a/src/libs/clangsupport/filepathid.cpp b/src/libs/clangsupport/filepathid.cpp index 7d059e0ea27..2491bc02d07 100644 --- a/src/libs/clangsupport/filepathid.cpp +++ b/src/libs/clangsupport/filepathid.cpp @@ -31,7 +31,7 @@ namespace ClangBackEnd { QDebug operator<<(QDebug debug, const FilePathId &filePathId) { - debug.nospace() << "(" << filePathId.directoryId << ", " << filePathId.filePathId << ")"; + debug.nospace() << "(" << filePathId.filePathId << ")"; return debug; } diff --git a/src/libs/clangsupport/filepathid.h b/src/libs/clangsupport/filepathid.h index 38762bd44bf..88426d93fcb 100644 --- a/src/libs/clangsupport/filepathid.h +++ b/src/libs/clangsupport/filepathid.h @@ -39,14 +39,14 @@ class FilePathId { public: constexpr FilePathId() = default; - FilePathId(int directoryId, int filePathId) - : directoryId(directoryId), - filePathId(filePathId) + + FilePathId(int filePathId) + : filePathId(filePathId) {} bool isValid() const { - return directoryId >= 0 && filePathId >= 0; + return filePathId >= 0; } friend bool operator==(FilePathId first, FilePathId second) @@ -66,7 +66,6 @@ public: friend QDataStream &operator<<(QDataStream &out, const FilePathId &filePathId) { - out << filePathId.directoryId; out << filePathId.filePathId; return out; @@ -74,14 +73,12 @@ public: friend QDataStream &operator>>(QDataStream &in, FilePathId &filePathId) { - in >> filePathId.directoryId; in >> filePathId.filePathId; return in; } public: - int directoryId = -1; int filePathId = -1; }; @@ -97,11 +94,7 @@ template<> struct hash<ClangBackEnd::FilePathId> using result_type = std::size_t; result_type operator()(const argument_type& filePathId) const { - long long hash = filePathId.directoryId; - hash = hash << 32; - hash += filePathId.filePathId; - - return std::hash<long long>{}(hash); + return std::hash<int>{}(filePathId.filePathId); } }; diff --git a/src/libs/clangsupport/filepathstorage.h b/src/libs/clangsupport/filepathstorage.h index 69388a45d24..5917504dbf3 100644 --- a/src/libs/clangsupport/filepathstorage.h +++ b/src/libs/clangsupport/filepathstorage.h @@ -165,14 +165,14 @@ public: return statement.template value<int>(directoryId, sourceName); } - Utils::SmallString fetchSourceName(int sourceId) + Sources::SourceNameAndDirectoryId fetchSourceNameAndDirectoryId(int sourceId) { try { Sqlite::DeferredTransaction transaction{m_statementFactory.database}; - ReadStatement &statement = m_statementFactory.selectSourceNameFromSourcesBySourceId; + ReadStatement &statement = m_statementFactory.selectSourceNameAndDirectoryIdFromSourcesBySourceId; - auto optionalSourceName = statement.template value<Utils::SmallString>(sourceId); + auto optionalSourceName = statement.template value<Sources::SourceNameAndDirectoryId, 2>(sourceId); if (!optionalSourceName) throw SourceNameIdDoesNotExists(); @@ -181,7 +181,7 @@ public: return optionalSourceName.value(); } catch (const Sqlite::StatementIsBusy &) { - return fetchSourceName(sourceId); + return fetchSourceNameAndDirectoryId(sourceId); } } diff --git a/src/libs/clangsupport/filepathstoragesources.h b/src/libs/clangsupport/filepathstoragesources.h index 7561aca908e..e76cb3b2cf6 100644 --- a/src/libs/clangsupport/filepathstoragesources.h +++ b/src/libs/clangsupport/filepathstoragesources.h @@ -69,6 +69,17 @@ public: int sourceId; Utils::PathString sourceName; }; + +class SourceNameAndDirectoryId +{ +public: + SourceNameAndDirectoryId(Utils::SmallStringView sourceName, int directoryId) + : sourceName(sourceName), directoryId(directoryId) + {} + + Utils::SmallString sourceName; + int directoryId = -1; +}; } // namespace ClangBackEnd } // namespace ClangBackEnd diff --git a/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h b/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h index 71e2c3e7734..dbf80717753 100644 --- a/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h +++ b/src/libs/clangsupport/filepathstoragesqlitestatementfactory.h @@ -65,8 +65,8 @@ public: "SELECT sourceId FROM sources WHERE directoryId = ? AND sourceName = ?", database }; - ReadStatement selectSourceNameFromSourcesBySourceId{ - "SELECT sourceName FROM sources WHERE sourceId = ?", + ReadStatement selectSourceNameAndDirectoryIdFromSourcesBySourceId{ + "SELECT sourceName, directoryId FROM sources WHERE sourceId = ?", database }; WriteStatement insertIntoSources{ diff --git a/src/libs/clangsupport/refactoringdatabaseinitializer.h b/src/libs/clangsupport/refactoringdatabaseinitializer.h index ab15cf81e0f..cba56475c82 100644 --- a/src/libs/clangsupport/refactoringdatabaseinitializer.h +++ b/src/libs/clangsupport/refactoringdatabaseinitializer.h @@ -99,7 +99,6 @@ public: table.addColumn("sourceId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey); const Sqlite::Column &directoryIdColumn = table.addColumn("directoryId", Sqlite::ColumnType::Integer); const Sqlite::Column &sourceNameColumn = table.addColumn("sourceName", Sqlite::ColumnType::Text); - table.addColumn("sourceType", Sqlite::ColumnType::Integer); table.addUniqueIndex({directoryIdColumn, sourceNameColumn}); table.initialize(database); @@ -139,6 +138,7 @@ public: table.setName("projectPartsSources"); const Sqlite::Column &projectPartIdColumn = table.addColumn("projectPartId", Sqlite::ColumnType::Integer); const Sqlite::Column &sourceIdColumn = table.addColumn("sourceId", Sqlite::ColumnType::Integer); + table.addColumn("sourceType", Sqlite::ColumnType::Integer); table.addUniqueIndex({sourceIdColumn, projectPartIdColumn}); table.addIndex({projectPartIdColumn}); @@ -167,6 +167,7 @@ public: table.addColumn("sourceId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey); table.addColumn("size", Sqlite::ColumnType::Integer); table.addColumn("lastModified", Sqlite::ColumnType::Integer); + table.addColumn("buildDependencyTimeStamp", Sqlite::ColumnType::Integer); table.addColumn("isInPrecompiledHeader", Sqlite::ColumnType::Integer); table.initialize(database); } |