Skip to content

Optimizations for extending bytes #10

@robin-nitrokey

Description

@robin-nitrokey

Currently, the heapless_bytes::Bytes functions mostly delegate to heapless::Vec. This means that we need to append new items one by one when extending although we could use more efficient operations for byte slices. Alternatives would be to re-implement these operations through Vec::as_mut_ptr and Vec::set_len, or to not use heapless::Vec at all and implement Bytes from scratch.

Affected operations:

  • extend_from_slice: calls push_unchecked for every element
  • resize/resize_zero/resize_to_capacity: calls push for every new element

If we would drop heapless::Vec, we could benefit from the (still unstable) MaybeUninit::copy_from_slice and MaybeUninit::fill.

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