Skip to content

Commit

Permalink
Permit reordering LeafNode fields
Browse files Browse the repository at this point in the history
Regardless of the order of the fields in the LeafNode, it is still guaranteed to
be a prefix of the InternalNode as that is still repr(C). Removing the repr(C)
annotation on the leaf node may permit the compiler to reorder the fields in a
more optimal fashion.
  • Loading branch information
Mark-Simulacrum committed Apr 1, 2020
1 parent 235938d commit 8fec670
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub const MIN_LEN: usize = B - 1;
pub const CAPACITY: usize = 2 * B - 1;

/// The underlying representation of leaf nodes.
#[repr(C)]
struct LeafNode<K, V> {
/// We use `*const` as opposed to `*mut` so as to be covariant in `K` and `V`.
/// This either points to an actual node or is null.
Expand All @@ -57,9 +56,6 @@ struct LeafNode<K, V> {
parent_idx: MaybeUninit<u16>,

/// The number of keys and values this node stores.
///
/// This next to `parent_idx` to encourage the compiler to join `len` and
/// `parent_idx` into the same 32-bit word, reducing space overhead.
len: u16,

/// The arrays storing the actual data of the node. Only the first `len` elements of each
Expand Down

0 comments on commit 8fec670

Please sign in to comment.