make including count of container elements non-optional

This commit is contained in:
Vern Paxson 2022-04-29 08:59:26 -07:00
parent b670046a69
commit edf276520a
5 changed files with 62 additions and 128 deletions

View file

@ -1322,14 +1322,12 @@ ValPtr ListVal::DoClone(CloneState* state)
return lv;
}
unsigned int ListVal::Footprint(bool count_entries) const
unsigned int ListVal::Footprint() const
{
unsigned int fp = 0;
for ( const auto& val : vals )
fp += val->Footprint(count_entries);
unsigned int fp = vals.size();
if ( count_entries )
fp += vals.size();
for ( const auto& val : vals )
fp += val->Footprint();
return fp;
}
@ -2685,9 +2683,9 @@ ValPtr TableVal::DoClone(CloneState* state)
return tv;
}
unsigned int TableVal::Footprint(bool count_entries) const
unsigned int TableVal::Footprint() const
{
unsigned int fp = 0;
unsigned int fp = table_val->Length();
for ( const auto& iter : *table_val )
{
@ -2695,14 +2693,11 @@ unsigned int TableVal::Footprint(bool count_entries) const
auto vl = table_hash->RecoverVals(*k);
auto v = iter.GetValue<TableEntryVal*>()->GetVal();
fp += vl->Footprint(count_entries);
fp += vl->Footprint();
if ( v )
fp += v->Footprint(count_entries);
fp += v->Footprint();
}
if ( count_entries )
fp += table_val->Length();
return fp;
}
@ -3071,7 +3066,7 @@ ValPtr RecordVal::DoClone(CloneState* state)
return rv;
}
unsigned int RecordVal::Footprint(bool count_entries) const
unsigned int RecordVal::Footprint() const
{
// Which records we're in the process of analyzing - used to
// avoid infinite recursion for circular types (which can only
@ -3084,8 +3079,8 @@ unsigned int RecordVal::Footprint(bool count_entries) const
pending_records.insert(this);
unsigned int fp = 0;
int n = NumFields();
unsigned int fp = n;
for ( auto i = 0; i < n; ++i )
{
@ -3094,12 +3089,9 @@ unsigned int RecordVal::Footprint(bool count_entries) const
auto f_i = GetField(i);
if ( f_i )
fp += f_i->Footprint(count_entries);
fp += f_i->Footprint();
}
if ( count_entries )
fp += n;
pending_records.erase(this);
return fp;
@ -3628,21 +3620,18 @@ bool VectorVal::Concretize(const TypePtr& t)
return true;
}
unsigned int VectorVal::Footprint(bool count_entries) const
unsigned int VectorVal::Footprint() const
{
unsigned int fp = 0;
auto n = vector_val->size();
unsigned int fp = n;
for ( auto i = 0U; i < n; ++i )
{
auto v = At(i);
if ( v )
fp += v->Footprint(count_entries);
fp += v->Footprint();
}
if ( count_entries )
fp += n;
return fp;
}