mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
Merge pull request #11191 from DeterminateSystems/hash-symbol
Use std::unordered_map for ValueMap
This commit is contained in:
commit
f9d55b4d51
3 changed files with 14 additions and 3 deletions
|
@ -42,7 +42,7 @@ class JSONSax : nlohmann::json_sax<json> {
|
||||||
auto attrs2 = state.buildBindings(attrs.size());
|
auto attrs2 = state.buildBindings(attrs.size());
|
||||||
for (auto & i : attrs)
|
for (auto & i : attrs)
|
||||||
attrs2.insert(i.first, i.second);
|
attrs2.insert(i.first, i.second);
|
||||||
parent->value(state).mkAttrs(attrs2.alreadySorted());
|
parent->value(state).mkAttrs(attrs2);
|
||||||
return std::move(parent);
|
return std::move(parent);
|
||||||
}
|
}
|
||||||
void add() override { v = nullptr; }
|
void add() override { v = nullptr; }
|
||||||
|
|
|
@ -70,6 +70,8 @@ public:
|
||||||
|
|
||||||
auto operator<=>(const Symbol other) const { return id <=> other.id; }
|
auto operator<=>(const Symbol other) const { return id <=> other.id; }
|
||||||
bool operator==(const Symbol other) const { return id == other.id; }
|
bool operator==(const Symbol other) const { return id == other.id; }
|
||||||
|
|
||||||
|
friend class std::hash<Symbol>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,3 +135,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct std::hash<nix::Symbol>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const nix::Symbol & s) const noexcept
|
||||||
|
{
|
||||||
|
return std::hash<decltype(s.id)>{}(s.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -494,11 +494,11 @@ void Value::mkBlackhole()
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
typedef std::vector<Value *, traceable_allocator<Value *>> ValueVector;
|
typedef std::vector<Value *, traceable_allocator<Value *>> ValueVector;
|
||||||
typedef std::map<Symbol, Value *, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Value *>>> ValueMap;
|
typedef std::unordered_map<Symbol, Value *, std::hash<Symbol>, std::equal_to<Symbol>, traceable_allocator<std::pair<const Symbol, Value *>>> ValueMap;
|
||||||
typedef std::map<Symbol, ValueVector, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, ValueVector>>> ValueVectorMap;
|
typedef std::map<Symbol, ValueVector, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, ValueVector>>> ValueVectorMap;
|
||||||
#else
|
#else
|
||||||
typedef std::vector<Value *> ValueVector;
|
typedef std::vector<Value *> ValueVector;
|
||||||
typedef std::map<Symbol, Value *> ValueMap;
|
typedef std::unordered_map<Symbol, Value *> ValueMap;
|
||||||
typedef std::map<Symbol, ValueVector> ValueVectorMap;
|
typedef std::map<Symbol, ValueVector> ValueVectorMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue