Skip to content

Commit 8fec670

Browse files
Permit reordering LeafNode fields
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.
1 parent 235938d commit 8fec670

File tree

1 file changed

+0
-4
lines changed
  • src/liballoc/collections/btree

1 file changed

+0
-4
lines changed

src/liballoc/collections/btree/node.rs

-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub const MIN_LEN: usize = B - 1;
4545
pub const CAPACITY: usize = 2 * B - 1;
4646

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

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

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

0 commit comments

Comments
 (0)