diff --git a/src/query.cc b/src/query.cc index 9689cc48..6b4d4b63 100644 --- a/src/query.cc +++ b/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& updates) { + std::vector&& 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& updates) { + std::vector&& 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& updates) { +void QueryDatabase::ImportOrUpdate(std::vector&& 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); diff --git a/src/query.h b/src/query.h index 9c205307..9119a9d1 100644 --- a/src/query.h +++ b/src/query.h @@ -409,9 +409,9 @@ struct QueryDatabase { // Insert the contents of |update| into |db|. void ApplyIndexUpdate(IndexUpdate* update); void ImportOrUpdate(const std::vector& updates); - void ImportOrUpdate(const std::vector& updates); - void ImportOrUpdate(const std::vector& updates); - void ImportOrUpdate(const std::vector& updates); + void ImportOrUpdate(std::vector&& updates); + void ImportOrUpdate(std::vector&& updates); + void ImportOrUpdate(std::vector&& updates); void UpdateSymbols(Maybe>* symbol_idx, SymbolKind kind, RawId idx); std::string_view GetSymbolDetailedName(RawId symbol_idx) const; std::string_view GetSymbolShortName(RawId symbol_idx) const; diff --git a/src/query_utils.cc b/src/query_utils.cc index 5762bef2..202a0bf9 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -3,6 +3,7 @@ #include "queue_manager.h" #include +#include namespace { diff --git a/src/utils.cc b/src/utils.cc index 7501601d..726eba11 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -13,8 +13,7 @@ #include #include #include -#include -#include +#include #include #include #include diff --git a/src/utils.h b/src/utils.h index a7fca9f0..5b985ba6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -137,14 +137,8 @@ void AddRange(std::vector* dest, const std::vector& to_add) { template void AddRange(std::vector* dest, std::vector&& to_add) { - for (T& x : to_add) - dest->push_back(std::move(x)); -} - -template -void PushRange(std::queue* dest, const std::vector& 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