mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/intrusiveptr-hash'
* origin/topic/jsiwek/intrusiveptr-hash: Change TableVal::ToMap() to return ValPtr-indexed maps Add std::hash specialization for IntrusivePtr Move IntrusivePtr relational operators to zeek namespace
This commit is contained in:
commit
2f69e32233
5 changed files with 27 additions and 9 deletions
9
CHANGES
9
CHANGES
|
@ -1,3 +1,12 @@
|
|||
4.1.0-dev.495 | 2021-04-07 11:12:13 -0700
|
||||
|
||||
* Change TableVal::ToMap() to return ValPtr-indexed maps (Jon Siwek, Corelight)
|
||||
|
||||
* Add std::hash specialization for IntrusivePtr (Jon Siwek, Corelight)
|
||||
|
||||
* Move IntrusivePtr relational operators to zeek namespace
|
||||
|
||||
Otherwise some cases relying on argument-dependent lookup (ADL) fail. (Jon Siwek, Corelight)
|
||||
|
||||
4.1.0-dev.490 | 2021-04-05 14:13:48 -0700
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.1.0-dev.490
|
||||
4.1.0-dev.495
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
namespace zeek {
|
||||
|
||||
|
@ -198,8 +199,6 @@ IntrusivePtr<T> cast_intrusive(IntrusivePtr<U> p) noexcept
|
|||
return {AdoptRef{}, static_cast<T*>(p.release())};
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
// -- comparison to nullptr ----------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -292,3 +291,15 @@ auto operator!=(const zeek::IntrusivePtr<T>& x, const zeek::IntrusivePtr<U>& y)
|
|||
{
|
||||
return x.get() != y.get();
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
// -- hashing ------------------------------------------------
|
||||
|
||||
namespace std {
|
||||
template <class T> struct hash<zeek::IntrusivePtr<T>> {
|
||||
// Hash of intrusive pointer is the same as hash of the raw pointer it holds.
|
||||
size_t operator()(const zeek::IntrusivePtr<T>& v) const noexcept
|
||||
{ return std::hash<T*>{}(v.get()); }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2311,9 +2311,9 @@ ListValPtr TableVal::ToPureListVal() const
|
|||
return ToListVal(tl[0]->Tag());
|
||||
}
|
||||
|
||||
std::unordered_map<Val*, ValPtr> TableVal::ToMap() const
|
||||
std::unordered_map<ValPtr, ValPtr> TableVal::ToMap() const
|
||||
{
|
||||
std::unordered_map<Val*, ValPtr> res;
|
||||
std::unordered_map<ValPtr, ValPtr> res;
|
||||
|
||||
for ( const auto& iter : *table_val )
|
||||
{
|
||||
|
@ -2321,7 +2321,7 @@ std::unordered_map<Val*, ValPtr> TableVal::ToMap() const
|
|||
auto v = iter.GetValue<TableEntryVal*>();
|
||||
auto vl = table_hash->RecoverVals(*k);
|
||||
|
||||
res[vl.release()] = v->GetVal();
|
||||
res[std::move(vl)] = v->GetVal();
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -896,9 +896,7 @@ public:
|
|||
ListValPtr ToPureListVal() const;
|
||||
|
||||
// Returns a map of index-to-value's. The value is nil for sets.
|
||||
// It's up to the caller to Unref() the index Val* when done
|
||||
// with it.
|
||||
std::unordered_map<Val*, ValPtr> ToMap() const;
|
||||
std::unordered_map<ValPtr, ValPtr> ToMap() const;
|
||||
|
||||
void SetAttrs(detail::AttributesPtr attrs);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue