mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Deprecate TableVal::Intersect(), replace with Intersection()
This commit is contained in:
parent
7e89c8f0df
commit
e5f66cd2e6
3 changed files with 17 additions and 9 deletions
|
@ -744,7 +744,7 @@ IntrusivePtr<Val> BinaryExpr::SetFold(Val* v1, Val* v2) const
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
case EXPR_AND:
|
case EXPR_AND:
|
||||||
return {AdoptRef{}, tv1->Intersect(tv2)};
|
return tv1->Intersection(*tv2);
|
||||||
|
|
||||||
case EXPR_OR:
|
case EXPR_OR:
|
||||||
{
|
{
|
||||||
|
|
|
@ -1664,12 +1664,12 @@ bool TableVal::RemoveFrom(Val* val) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TableVal* TableVal::Intersect(const TableVal* tv) const
|
IntrusivePtr<TableVal> TableVal::Intersection(const TableVal& tv) const
|
||||||
{
|
{
|
||||||
TableVal* result = new TableVal(table_type);
|
auto result = make_intrusive<TableVal>(table_type);
|
||||||
|
|
||||||
const PDict<TableEntryVal>* t0 = AsTable();
|
const PDict<TableEntryVal>* t0 = AsTable();
|
||||||
const PDict<TableEntryVal>* t1 = tv->AsTable();
|
const PDict<TableEntryVal>* t1 = tv.AsTable();
|
||||||
PDict<TableEntryVal>* t2 = result->AsNonConstTable();
|
PDict<TableEntryVal>* t2 = result->AsNonConstTable();
|
||||||
|
|
||||||
// Figure out which is smaller; assign it to t1.
|
// Figure out which is smaller; assign it to t1.
|
||||||
|
|
18
src/Val.h
18
src/Val.h
|
@ -795,11 +795,19 @@ public:
|
||||||
// Returns true if the addition typechecked, false if not.
|
// Returns true if the addition typechecked, false if not.
|
||||||
bool RemoveFrom(Val* v) const override;
|
bool RemoveFrom(Val* v) const override;
|
||||||
|
|
||||||
// Returns a new table that is the intersection of this
|
/**
|
||||||
// table and the given table. Intersection is just done
|
* Returns a new table that is the intersection of this table
|
||||||
// on index, not on yield value, so this really only makes
|
* and the given table. Intersection is done only on index, not on
|
||||||
// sense for sets.
|
* yield value, so this generally makes most sense to use for sets,
|
||||||
TableVal* Intersect(const TableVal* v) const;
|
* not tables.
|
||||||
|
* @param v The intersecting table.
|
||||||
|
* @return The intersection of this table and the given one.
|
||||||
|
*/
|
||||||
|
IntrusivePtr<TableVal> Intersection(const TableVal& v) const;
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use Intersection() instead.")]]
|
||||||
|
TableVal* Intersect(const TableVal* v) const
|
||||||
|
{ return Intersection(*v).release(); }
|
||||||
|
|
||||||
// Returns true if this set contains the same members as the
|
// Returns true if this set contains the same members as the
|
||||||
// given set. Note that comparisons are done using hash keys,
|
// given set. Note that comparisons are done using hash keys,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue