mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 00:55:08 +00:00
Add sparsepp as a replacement for sparsehash
This commit is contained in:
parent
cd50eb9e35
commit
eb83ba26e1
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
|||||||
[submodule "third_party/sparsehash"]
|
[submodule "third_party/sparsehash"]
|
||||||
path = third_party/sparsehash
|
path = third_party/sparsehash
|
||||||
url = https://github.com/sparsehash/sparsehash
|
url = https://github.com/sparsehash/sparsehash
|
||||||
|
[submodule "third_party/sparsepp"]
|
||||||
|
path = third_party/sparsepp
|
||||||
|
url = https://github.com/greg7mdp/sparsepp
|
||||||
|
11
src/query.cc
11
src/query.cc
@ -72,8 +72,9 @@ void AddMergeableRange(
|
|||||||
// time at the cost of some additional memory.
|
// time at the cost of some additional memory.
|
||||||
|
|
||||||
// Build lookup table.
|
// Build lookup table.
|
||||||
google::dense_hash_map<TId, size_t, std::hash<TId>> id_to_index;
|
//google::dense_hash_map<TId, size_t, std::hash<TId>> id_to_index;
|
||||||
id_to_index.set_empty_key(TId(-1));
|
//id_to_index.set_empty_key(TId(-1));
|
||||||
|
spp::sparse_hash_map<TId, size_t> id_to_index;
|
||||||
id_to_index.resize(dest->size());
|
id_to_index.resize(dest->size());
|
||||||
for (size_t i = 0; i < dest->size(); ++i)
|
for (size_t i = 0; i < dest->size(); ++i)
|
||||||
id_to_index[(*dest)[i].id] = i;
|
id_to_index[(*dest)[i].id] = i;
|
||||||
@ -356,17 +357,17 @@ IdMap::IdMap(QueryDatabase* query_db, const IdCache& local_ids)
|
|||||||
: local_ids(local_ids) {
|
: local_ids(local_ids) {
|
||||||
primary_file = GetQueryFileIdFromPath(query_db, local_ids.primary_file);
|
primary_file = GetQueryFileIdFromPath(query_db, local_ids.primary_file);
|
||||||
|
|
||||||
cached_type_ids_.set_empty_key(IndexTypeId(-1));
|
//cached_type_ids_.set_empty_key(IndexTypeId(-1));
|
||||||
cached_type_ids_.resize(local_ids.type_id_to_usr.size());
|
cached_type_ids_.resize(local_ids.type_id_to_usr.size());
|
||||||
for (const auto& entry : local_ids.type_id_to_usr)
|
for (const auto& entry : local_ids.type_id_to_usr)
|
||||||
cached_type_ids_[entry.first] = GetQueryTypeIdFromUsr(query_db, entry.second);
|
cached_type_ids_[entry.first] = GetQueryTypeIdFromUsr(query_db, entry.second);
|
||||||
|
|
||||||
cached_func_ids_.set_empty_key(IndexFuncId(-1));
|
//cached_func_ids_.set_empty_key(IndexFuncId(-1));
|
||||||
cached_func_ids_.resize(local_ids.func_id_to_usr.size());
|
cached_func_ids_.resize(local_ids.func_id_to_usr.size());
|
||||||
for (const auto& entry : local_ids.func_id_to_usr)
|
for (const auto& entry : local_ids.func_id_to_usr)
|
||||||
cached_func_ids_[entry.first] = GetQueryFuncIdFromUsr(query_db, entry.second);
|
cached_func_ids_[entry.first] = GetQueryFuncIdFromUsr(query_db, entry.second);
|
||||||
|
|
||||||
cached_var_ids_.set_empty_key(IndexVarId(-1));
|
//cached_var_ids_.set_empty_key(IndexVarId(-1));
|
||||||
cached_var_ids_.resize(local_ids.var_id_to_usr.size());
|
cached_var_ids_.resize(local_ids.var_id_to_usr.size());
|
||||||
for (const auto& entry : local_ids.var_id_to_usr)
|
for (const auto& entry : local_ids.var_id_to_usr)
|
||||||
cached_var_ids_[entry.first] = GetQueryVarIdFromUsr(query_db, entry.second);
|
cached_var_ids_[entry.first] = GetQueryVarIdFromUsr(query_db, entry.second);
|
||||||
|
16
src/query.h
16
src/query.h
@ -3,7 +3,7 @@
|
|||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
|
|
||||||
#include <sparsehash/dense_hash_map>
|
#include <sparsepp/spp.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@ -257,10 +257,11 @@ struct QueryDatabase {
|
|||||||
std::vector<QueryVar> vars;
|
std::vector<QueryVar> vars;
|
||||||
|
|
||||||
// Lookup symbol based on a usr.
|
// Lookup symbol based on a usr.
|
||||||
google::dense_hash_map<Usr, SymbolIdx> usr_to_symbol;
|
spp::sparse_hash_map<Usr, SymbolIdx> usr_to_symbol;
|
||||||
|
//google::dense_hash_map<Usr, SymbolIdx> usr_to_symbol;
|
||||||
|
|
||||||
QueryDatabase() {
|
QueryDatabase() {
|
||||||
usr_to_symbol.set_empty_key("");
|
//usr_to_symbol.set_empty_key("");
|
||||||
}
|
}
|
||||||
//std::unordered_map<Usr, SymbolIdx> usr_to_symbol;
|
//std::unordered_map<Usr, SymbolIdx> usr_to_symbol;
|
||||||
|
|
||||||
@ -310,7 +311,10 @@ struct IdMap {
|
|||||||
SymbolIdx ToSymbol(IndexFuncId id) const;
|
SymbolIdx ToSymbol(IndexFuncId id) const;
|
||||||
SymbolIdx ToSymbol(IndexVarId id) const;
|
SymbolIdx ToSymbol(IndexVarId id) const;
|
||||||
private:
|
private:
|
||||||
google::dense_hash_map<IndexTypeId, QueryTypeId, std::hash<IndexTypeId>> cached_type_ids_;
|
spp::sparse_hash_map<IndexTypeId, QueryTypeId> cached_type_ids_;
|
||||||
google::dense_hash_map<IndexFuncId, QueryFuncId, std::hash<IndexFuncId>> cached_func_ids_;
|
spp::sparse_hash_map<IndexFuncId, QueryFuncId> cached_func_ids_;
|
||||||
google::dense_hash_map<IndexVarId, QueryVarId, std::hash<IndexVarId>> cached_var_ids_;
|
spp::sparse_hash_map<IndexVarId, QueryVarId> cached_var_ids_;
|
||||||
|
//google::dense_hash_map<IndexTypeId, QueryTypeId, std::hash<IndexTypeId>> cached_type_ids_;
|
||||||
|
//google::dense_hash_map<IndexFuncId, QueryFuncId, std::hash<IndexFuncId>> cached_func_ids_;
|
||||||
|
//google::dense_hash_map<IndexVarId, QueryVarId, std::hash<IndexVarId>> cached_var_ids_;
|
||||||
};
|
};
|
||||||
|
1
third_party/sparsepp
vendored
Submodule
1
third_party/sparsepp
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b1d54fbe547cab3a13d181f16f1de758d6827f81
|
Loading…
Reference in New Issue
Block a user