VectorVal: Embed vector_val

Similar motivation as for RecordVal, save an extra malloc/free
and pointer indirection.

This breaks the `auto& RawVec()` API which previously returned
a reference to the std::vector*. It now returns a reference
to the vector instead. It's commented as intended for internal
and compiled code, so even though it's public API,

The previous `std::vector<std::optional<ZVal>>*&` return type was also very
likely not intended (all consumers just dereference it anyhow). I'm certain
this API was never meant to modify the actual pointer value.

I've switched to explicit typing, too.
This commit is contained in:
Arne Welzel 2023-09-21 15:06:50 +02:00
parent f362935a66
commit cbaf43e8ea
7 changed files with 70 additions and 81 deletions

View file

@ -314,13 +314,13 @@ void ValTrace::TraceTable(const TableValPtr& tv)
void ValTrace::TraceVector(const VectorValPtr& vv)
{
auto& vec = vv->RawVec();
auto n = vec->size();
auto n = vec.size();
auto& yt = vv->RawYieldType();
auto& yts = vv->RawYieldTypes();
for ( auto i = 0U; i < n; ++i )
{
auto& elem = (*vec)[i];
auto& elem = vec[i];
if ( elem )
{
auto& t = yts ? (*yts)[i] : yt;