mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
Move ImportOrUpdate and header cleanup
This commit is contained in:
parent
e9f45dd601
commit
55c7519e93
19
src/query.cc
19
src/query.cc
@ -791,19 +791,19 @@ void QueryDatabase::ApplyIndexUpdate(IndexUpdate* update) {
|
||||
ImportOrUpdate(update->files_def_update);
|
||||
|
||||
RemoveUsrs(SymbolKind::Type, update->types_removed);
|
||||
ImportOrUpdate(update->types_def_update);
|
||||
ImportOrUpdate(std::move(update->types_def_update));
|
||||
HANDLE_MERGEABLE(types_derived, derived, types);
|
||||
HANDLE_MERGEABLE(types_instances, instances, types);
|
||||
HANDLE_MERGEABLE(types_uses, uses, types);
|
||||
|
||||
RemoveUsrs(SymbolKind::Func, update->funcs_removed);
|
||||
ImportOrUpdate(update->funcs_def_update);
|
||||
ImportOrUpdate(std::move(update->funcs_def_update));
|
||||
HANDLE_MERGEABLE(funcs_declarations, declarations, funcs);
|
||||
HANDLE_MERGEABLE(funcs_derived, derived, funcs);
|
||||
HANDLE_MERGEABLE(funcs_callers, callers, funcs);
|
||||
|
||||
RemoveUsrs(SymbolKind::Var, update->vars_removed);
|
||||
ImportOrUpdate(update->vars_def_update);
|
||||
ImportOrUpdate(std::move(update->vars_def_update));
|
||||
HANDLE_MERGEABLE(vars_declarations, declarations, vars);
|
||||
HANDLE_MERGEABLE(vars_uses, uses, vars);
|
||||
|
||||
@ -827,7 +827,7 @@ void QueryDatabase::ImportOrUpdate(
|
||||
}
|
||||
|
||||
void QueryDatabase::ImportOrUpdate(
|
||||
const std::vector<QueryType::DefUpdate>& updates) {
|
||||
std::vector<QueryType::DefUpdate>&& updates) {
|
||||
// This function runs on the querydb thread.
|
||||
|
||||
for (auto& def : updates) {
|
||||
@ -842,7 +842,7 @@ void QueryDatabase::ImportOrUpdate(
|
||||
// Keep the existing definition if it is higher quality.
|
||||
if (!(existing.def && existing.def->definition_spelling &&
|
||||
!def.value.definition_spelling)) {
|
||||
existing.def = def.value;
|
||||
existing.def = std::move(def.value);
|
||||
UpdateSymbols(&existing.symbol_idx, SymbolKind::Type,
|
||||
it->second.id);
|
||||
}
|
||||
@ -850,7 +850,7 @@ void QueryDatabase::ImportOrUpdate(
|
||||
}
|
||||
|
||||
void QueryDatabase::ImportOrUpdate(
|
||||
const std::vector<QueryFunc::DefUpdate>& updates) {
|
||||
std::vector<QueryFunc::DefUpdate>&& updates) {
|
||||
// This function runs on the querydb thread.
|
||||
|
||||
for (auto& def : updates) {
|
||||
@ -865,15 +865,14 @@ void QueryDatabase::ImportOrUpdate(
|
||||
// Keep the existing definition if it is higher quality.
|
||||
if (!(existing.def && existing.def->definition_spelling &&
|
||||
!def.value.definition_spelling)) {
|
||||
existing.def = def.value;
|
||||
existing.def = std::move(def.value);
|
||||
UpdateSymbols(&existing.symbol_idx, SymbolKind::Func,
|
||||
it->second.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QueryDatabase::ImportOrUpdate(
|
||||
const std::vector<QueryVar::DefUpdate>& updates) {
|
||||
void QueryDatabase::ImportOrUpdate(std::vector<QueryVar::DefUpdate>&& updates) {
|
||||
// This function runs on the querydb thread.
|
||||
|
||||
for (auto& def : updates) {
|
||||
@ -888,7 +887,7 @@ void QueryDatabase::ImportOrUpdate(
|
||||
// Keep the existing definition if it is higher quality.
|
||||
if (!(existing.def && existing.def->definition_spelling &&
|
||||
!def.value.definition_spelling)) {
|
||||
existing.def = def.value;
|
||||
existing.def = std::move(def.value);
|
||||
if (!def.value.is_local())
|
||||
UpdateSymbols(&existing.symbol_idx, SymbolKind::Var,
|
||||
it->second.id);
|
||||
|
@ -409,9 +409,9 @@ struct QueryDatabase {
|
||||
// Insert the contents of |update| into |db|.
|
||||
void ApplyIndexUpdate(IndexUpdate* update);
|
||||
void ImportOrUpdate(const std::vector<QueryFile::DefUpdate>& updates);
|
||||
void ImportOrUpdate(const std::vector<QueryType::DefUpdate>& updates);
|
||||
void ImportOrUpdate(const std::vector<QueryFunc::DefUpdate>& updates);
|
||||
void ImportOrUpdate(const std::vector<QueryVar::DefUpdate>& updates);
|
||||
void ImportOrUpdate(std::vector<QueryType::DefUpdate>&& updates);
|
||||
void ImportOrUpdate(std::vector<QueryFunc::DefUpdate>&& updates);
|
||||
void ImportOrUpdate(std::vector<QueryVar::DefUpdate>&& updates);
|
||||
void UpdateSymbols(Maybe<Id<void>>* symbol_idx, SymbolKind kind, RawId idx);
|
||||
std::string_view GetSymbolDetailedName(RawId symbol_idx) const;
|
||||
std::string_view GetSymbolShortName(RawId symbol_idx) const;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "queue_manager.h"
|
||||
|
||||
#include <climits>
|
||||
#include <queue>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -13,8 +13,7 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
12
src/utils.h
12
src/utils.h
@ -5,7 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -137,14 +137,8 @@ void AddRange(std::vector<T>* dest, const std::vector<T>& to_add) {
|
||||
|
||||
template <typename T>
|
||||
void AddRange(std::vector<T>* dest, std::vector<T>&& to_add) {
|
||||
for (T& x : to_add)
|
||||
dest->push_back(std::move(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PushRange(std::queue<T>* dest, const std::vector<T>& to_add) {
|
||||
for (const T& e : to_add)
|
||||
dest->push(e);
|
||||
dest->push_back(dest->end(), std::make_move_iterator(to_add.begin()),
|
||||
std::make_move_iterator(to_add.end()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user