Deprecate ListVal::ConvertToSet(), add ListVal::ToSetVal()

This commit is contained in:
Jon Siwek 2020-05-05 10:40:55 -07:00
parent 2cfbbd8cdb
commit df65d1e829
4 changed files with 15 additions and 12 deletions

View file

@ -1226,7 +1226,7 @@ void ListVal::Append(Val* v)
type->AsTypeList()->Append({NewRef{}, v->Type()});
}
TableVal* ListVal::ConvertToSet() const
IntrusivePtr<TableVal> ListVal::ToSetVal() const
{
if ( tag == TYPE_ANY )
Internal("conversion of heterogeneous list to set");
@ -1235,7 +1235,7 @@ TableVal* ListVal::ConvertToSet() const
IntrusivePtr{NewRef{}, type->AsTypeList()->PureType()});
set_index->Append(base_type(tag));
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
TableVal* t = new TableVal(std::move(s));
auto t = make_intrusive<TableVal>(std::move(s));
for ( const auto& val : vals )
t->Assign(val, nullptr);
@ -1243,6 +1243,11 @@ TableVal* ListVal::ConvertToSet() const
return t;
}
TableVal* ListVal::ConvertToSet() const
{
return ToSetVal().release();
}
void ListVal::Describe(ODesc* d) const
{
if ( d->IsBinary() || d->IsPortable() )