TablePatternMatcher: Use unique_ptr

This commit is contained in:
Arne Welzel 2023-11-01 14:47:10 +01:00
parent c8bab6a0ec
commit 43a5473919

View file

@ -1436,15 +1436,11 @@ public:
TablePatternMatcher(const TableVal* _tbl, TypePtr _yield) : tbl(_tbl) { TablePatternMatcher(const TableVal* _tbl, TypePtr _yield) : tbl(_tbl) {
vtype = make_intrusive<VectorType>(std::move(_yield)); vtype = make_intrusive<VectorType>(std::move(_yield));
} }
~TablePatternMatcher() { Clear(); }
void Insert(ValPtr pat, ValPtr yield) { Clear(); } void Insert(ValPtr pat, ValPtr yield) { Clear(); }
void Remove(ValPtr pat) { Clear(); } void Remove(ValPtr pat) { Clear(); }
void Clear() { void Clear() { matcher.reset(); }
delete matcher;
matcher = nullptr;
}
VectorValPtr Lookup(const StringVal* s); VectorValPtr Lookup(const StringVal* s);
@ -1461,7 +1457,7 @@ private:
// from having to re-build the matcher on every insert/delete in // from having to re-build the matcher on every insert/delete in
// the common case that a whole bunch of those are done in a single // the common case that a whole bunch of those are done in a single
// batch. // batch.
RE_DisjunctiveMatcher* matcher = nullptr; std::unique_ptr<RE_DisjunctiveMatcher> matcher = nullptr;
// Maps matcher values to corresponding yields. When building the // Maps matcher values to corresponding yields. When building the
// matcher we insert a nil at the head to accommodate how // matcher we insert a nil at the head to accommodate how
@ -1511,7 +1507,7 @@ void TablePatternMatcher::Build() {
hash_key_vals.push_back(std::move(vl)); hash_key_vals.push_back(std::move(vl));
} }
matcher = new RE_DisjunctiveMatcher(patterns); matcher = std::make_unique<RE_DisjunctiveMatcher>(patterns);
} }
TableVal::TableVal(TableTypePtr t, detail::AttributesPtr a) : Val(t) { TableVal::TableVal(TableTypePtr t, detail::AttributesPtr a) : Val(t) {