Skip to content

Structure VarZeroSlice as an "enum" #5564

Open
@Manishearth

Description

@Manishearth

#5378 is adding VarZeroLengthlessSlice. However, it cannot be used inside VarZeroSlice because VarZeroSlice has an optimization where empty slices are represented as the empty array, so we cannot do

struct VarZeroSlice<T, F> {
   length: RawBytesULE<4>,
   indices_and_data: VarZeroLengthlessSlice<T, F>,
}

However, @sffc had an idea. We could write a very simple abstraction that wraps [u8] which produces an Option<&NonemptyVarZeroSlice>, and NonemptyVarZeroSlice is represented as above. This is a simple optimization.

I'm not considering this a part of #5378 but I think it should be on the cards for the future! It's purely internal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-zerovecComponent: Yoke, ZeroVec, DataBake

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions