-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The StreamID struct is defined like this:
/// A struct representing a stream ID.
#[derive(Debug, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct StreamID {
pub(crate) id: Vec<u8>,
}
The vector is unnecessary - in the current format, CDC stream IDs are always constant size and have 128 bits. Keeping it as a vector is wasteful, especially that the StreamID
struct is embedded within the CDCRow
objects which can be created by the library in large quantities.
Proposal: change it to:
pub struct StreamID {
pub(crate) repr: StreamIDRepr,
}
enum StreamIDRepr {
StandardSize([u8; 16]),
NonStandardSize(Vec<u8>),
}
Thanks to the null pointer optimization, the new struct should have the same size as the old one. We are not reducing generality while optimizing the case that will practically happen 100% of the time.
wprzytula
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request