Val: TableVal::Delete() returns IntrusivePtr

This commit is contained in:
Max Kellermann 2020-03-04 20:58:38 +01:00
parent 6495193aae
commit d2961c72e1
4 changed files with 10 additions and 12 deletions

View file

@ -1598,7 +1598,7 @@ int TableVal::RemoveFrom(Val* val) const
// OTOH, they are both the same type, so as long as
// we don't have hash keys that are keyed per dictionary,
// it should work ...
Unref(t->Delete(k));
t->Delete(k);
delete k;
}
@ -2000,7 +2000,7 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe
in_change_func = false;
}
Val* TableVal::Delete(const Val* index)
IntrusivePtr<Val> TableVal::Delete(const Val* index)
{
HashKey* k = ComputeHash(index);
TableEntryVal* v = k ? AsNonConstTable()->RemoveEntry(k) : 0;
@ -2017,10 +2017,10 @@ Val* TableVal::Delete(const Val* index)
if ( change_func )
CallChangeFunc(index, va.get(), ELEMENT_REMOVED);
return va.release();
return va;
}
Val* TableVal::Delete(const HashKey* k)
IntrusivePtr<Val> TableVal::Delete(const HashKey* k)
{
TableEntryVal* v = AsNonConstTable()->RemoveEntry(k);
IntrusivePtr<Val> va{NewRef{}, v ? (v->Value() ? v->Value() : this) : nullptr};
@ -2042,7 +2042,7 @@ Val* TableVal::Delete(const HashKey* k)
CallChangeFunc(index.get(), va.get(), ELEMENT_REMOVED);
}
return va.release();
return va;
}
ListVal* TableVal::ConvertToList(TypeTag t) const