Skip to content

Partial sample initialization #1558

@PeakKS

Description

@PeakKS

Brief feature description

It would be nice to have the option to partially initialize a sample. I would create an uninitialized sample based on some maximum capacity of bytes then fill in the data actually received, and then create an initialized sample from those subset of bytes that were actually initialized.

Detailed information

For serialization, it may be expensive to calculate the exact serialized size for something, but much cheaper to figure out a size known to be large enough to contain the serialized data. So an uninitialized sample could be allocated with that cheap function, then the actual serialization can occur, returning the number of bytes actually used, which can then be used to shrink to the final initialized sample.

It would not be necessary for the next sample to reclaim the excess bytes that were not initialized, the overhead should be minimal. The feature would only be about making the initialized sample "correct" without requiring extra metadata of the actual size in a user header.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions