ListVal method to clear the list to allow reusing w/o new construction

This commit is contained in:
Vern Paxson 2024-08-05 09:14:55 +01:00 committed by Arne Welzel
parent 5d37e6bb5c
commit 3962810e4b
2 changed files with 12 additions and 0 deletions

View file

@ -341,6 +341,9 @@ public:
void Append(TypePtr t); void Append(TypePtr t);
void AppendEvenIfNotPure(TypePtr t); void AppendEvenIfNotPure(TypePtr t);
// Resets the list to be empty.
void Clear() { types.clear(); }
detail::TraversalCode Traverse(detail::TraversalCallback* cb) const override; detail::TraversalCode Traverse(detail::TraversalCallback* cb) const override;
protected: protected:

View file

@ -684,6 +684,15 @@ public:
*/ */
void Append(ValPtr v); void Append(ValPtr v);
/**
* Empties the list.
* @param v the value to append.
*/
void Clear() {
vals.clear();
type->AsTypeList()->Clear();
}
// Returns a Set representation of the list (which must be homogeneous). // Returns a Set representation of the list (which must be homogeneous).
TableValPtr ToSetVal() const; TableValPtr ToSetVal() const;