From da756c9a4c8a0a3dd8876b1539a801f1690204cd Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Thu, 13 Jul 2017 02:25:54 +0200 Subject: [PATCH] src: Improved code view performance * fixed slow annotation hovering * improved retrieving source locations for whole files --- src/lib/data/PersistentStorage.cpp | 12 ++++++------ src/lib/data/SqliteIndexStorage.cpp | 2 +- src/lib/utility/utility.h | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index bd7d673d..2a39480f 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -1299,26 +1299,26 @@ std::shared_ptr PersistentStorage::getSourceLocationsF { TRACE(); - std::vector fileIds; + std::vector filePaths; std::vector nonFileIds; for (const Id tokenId : tokenIds) { - if (getFileNodePath(tokenId).empty()) + FilePath path = getFileNodePath(tokenId); + if (path.empty()) { nonFileIds.push_back(tokenId); } else { - fileIds.push_back(tokenId); + filePaths.push_back(path); } } std::shared_ptr collection = std::make_shared(); - - for (const StorageFile& file : m_sqliteIndexStorage.getAllByIds(fileIds)) + for (const FilePath& path : filePaths) { - collection->addSourceLocationFile(m_sqliteIndexStorage.getSourceLocationsForFile(FilePath(file.filePath))); + collection->addSourceLocationFile(std::make_shared(path, true, false)); } if (nonFileIds.size()) diff --git a/src/lib/data/SqliteIndexStorage.cpp b/src/lib/data/SqliteIndexStorage.cpp index ebd472a3..ced7e9df 100644 --- a/src/lib/data/SqliteIndexStorage.cpp +++ b/src/lib/data/SqliteIndexStorage.cpp @@ -793,7 +793,7 @@ std::vector> SqliteIndexStorage::getIndices( SqliteDatabaseIndex("occurrence_element_id_index", "occurrence(element_id)") )); indices.push_back(std::make_pair( - STORAGE_MODE_CLEAR, + STORAGE_MODE_READ | STORAGE_MODE_CLEAR, SqliteDatabaseIndex("occurrence_source_location_id_index", "occurrence(source_location_id)") )); indices.push_back(std::make_pair( diff --git a/src/lib/utility/utility.h b/src/lib/utility/utility.h index 0234ed71..0644f386 100644 --- a/src/lib/utility/utility.h +++ b/src/lib/utility/utility.h @@ -93,9 +93,18 @@ namespace utility template bool shareElement(const std::set& a, const std::set& b) { - std::set c(a.begin(), a.end()); - c.insert(b.begin(), b.end()); - return a.size() + b.size() != c.size(); + const std::set* aPtr = a.size() > b.size() ? &a : &b; + const std::set* bPtr = aPtr == &a ? &b : &a; + + for (const T& bt : *bPtr) + { + if (aPtr->find(bt) != aPtr->end()) + { + return true; + } + } + + return false; } ApplicationArchitectureType getApplicationArchitectureType();