mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Provide std::hash<Symbol>
This commit is contained in:
parent
c274e005b6
commit
6d843ce9fe
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; }
|
||||||
|
|
|
@ -69,6 +69,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>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,3 +134,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…
Add table
Add a link
Reference in a new issue