Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Remove key_size() method from Column trait
Browse files Browse the repository at this point in the history
This helper simply called std::mem::size_of<Self::Index>(). However, all
of the underlying functions that create keys manually copy fields into a
byte array. The fields are copied in end-to-end whereas size_of() might
include alignment bytes.

That is, a (u64, u32) only has 12 bytes of "data", but it would have
size 16 due to the 4 alignment padding bytes that would be added to get
the u32 (size 4) aligned with the u64 (size 8).
  • Loading branch information
Steven Czabaniuk committed Nov 17, 2023
1 parent eb35a5a commit ae2bea0
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,6 @@ impl Rocks {
pub trait Column {
type Index;

fn key_size() -> usize {
std::mem::size_of::<Self::Index>()
}

fn key(index: Self::Index) -> Vec<u8>;
fn index(key: &[u8]) -> Self::Index;
// This trait method is primarily used by `Database::delete_range_cf()`, and is therefore only
Expand Down

0 comments on commit ae2bea0

Please sign in to comment.