From b85cfc6fe4f8bf28cf18964a2cee83753ceb89f6 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 20 May 2020 16:00:43 -0700 Subject: [PATCH] Deprecate TableVal IsSubsetOf and EqualTo taking Val*, use Val& --- src/Expr.cc | 8 ++++---- src/Val.cc | 8 ++++---- src/Val.h | 12 ++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Expr.cc b/src/Expr.cc index 7b0d8e8f73..8f28bfdbb8 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -767,19 +767,19 @@ IntrusivePtr BinaryExpr::SetFold(Val* v1, Val* v2) const } case EXPR_EQ: - res = tv1->EqualTo(tv2); + res = tv1->EqualTo(*tv2); break; case EXPR_NE: - res = ! tv1->EqualTo(tv2); + res = ! tv1->EqualTo(*tv2); break; case EXPR_LT: - res = tv1->IsSubsetOf(tv2) && tv1->Size() < tv2->Size(); + res = tv1->IsSubsetOf(*tv2) && tv1->Size() < tv2->Size(); break; case EXPR_LE: - res = tv1->IsSubsetOf(tv2); + res = tv1->IsSubsetOf(*tv2); break; case EXPR_GE: diff --git a/src/Val.cc b/src/Val.cc index 6ba6c29db4..5213a916a3 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1695,10 +1695,10 @@ IntrusivePtr TableVal::Intersection(const TableVal& tv) const return result; } -bool TableVal::EqualTo(const TableVal* tv) const +bool TableVal::EqualTo(const TableVal& tv) const { const PDict* t0 = AsTable(); - const PDict* t1 = tv->AsTable(); + const PDict* t1 = tv.AsTable(); if ( t0->Length() != t1->Length() ) return false; @@ -1722,10 +1722,10 @@ bool TableVal::EqualTo(const TableVal* tv) const return true; } -bool TableVal::IsSubsetOf(const TableVal* tv) const +bool TableVal::IsSubsetOf(const TableVal& tv) const { const PDict* t0 = AsTable(); - const PDict* t1 = tv->AsTable(); + const PDict* t1 = tv.AsTable(); if ( t0->Length() > t1->Length() ) return false; diff --git a/src/Val.h b/src/Val.h index f5f567e06b..f4476bdd20 100644 --- a/src/Val.h +++ b/src/Val.h @@ -813,11 +813,19 @@ public: // given set. Note that comparisons are done using hash keys, // so errors can arise for compound sets such as sets-of-sets. // See https://bro-tracker.atlassian.net/browse/BIT-1949. - bool EqualTo(const TableVal* v) const; + bool EqualTo(const TableVal& v) const; + + [[deprecated("Remove in v4.1. Pass TableVal& instead.")]] + bool EqualTo(const TableVal* v) const + { return EqualTo(*v); } // Returns true if this set is a subset (not necessarily proper) // of the given set. - bool IsSubsetOf(const TableVal* v) const; + bool IsSubsetOf(const TableVal& v) const; + + [[deprecated("Remove in v4.1. Pass TableVal& instead.")]] + bool IsSubsetOf(const TableVal* v) const + { return IsSubsetOf(*v); } // Expands any lists in the index into multiple initializations. // Returns true if the initializations typecheck, false if not.