Skip to content

Commit

Permalink
benches: hide the Clone impl
Browse files Browse the repository at this point in the history
  • Loading branch information
cchudant committed Apr 3, 2024
1 parent 2d151d7 commit af3d8a8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ version = "0.1.0"
default = ["std", "rocksdb"]
rocksdb = ["dep:rocksdb"]
std = ["parity-scale-codec/std", "bitvec/std", "starknet-types-core/std"]
# internal
bench = []

[dependencies]
bitvec = { version = "1", default-features = false, features = ["alloc"] }
Expand Down Expand Up @@ -48,4 +50,5 @@ criterion = "0.5.1"

[[bench]]
name = "storage"
required-features = ["bench"]
harness = false
4 changes: 2 additions & 2 deletions src/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Change {
}

#[derive(Debug, Default)]
#[derive(Clone)]
#[cfg_attr(feature = "bench", derive(Clone))]
pub struct ChangeBatch(pub(crate) HashMap<TrieKey, Change>);

const KEY_SEPARATOR: u8 = 0x00;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl ChangeBatch {
}
}

#[derive(Clone)]
#[cfg_attr(feature = "bench", derive(Clone))]
pub struct ChangeStore<ID>
where
ID: Id,
Expand Down
2 changes: 1 addition & 1 deletion src/key_value_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
};

/// Crate Trie <= KeyValueDB => BonsaiDatabase
#[derive(Clone)]
#[cfg_attr(feature = "bench", derive(Clone))]
pub struct KeyValueDB<DB, ID>
where
DB: BonsaiDatabase,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ where
tries: MerkleTrees<H, DB, ChangeID>,
}

#[cfg(feature = "bench")]
impl<ChangeID, DB, H> Clone for BonsaiStorage<ChangeID, DB, H>
where
DB: BonsaiDatabase + Clone,
Expand Down
2 changes: 2 additions & 0 deletions src/trie/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub(crate) struct MerkleTrees<H: StarkHash + Send + Sync, DB: BonsaiDatabase, Co
pub trees: HashMap<Vec<u8>, MerkleTree<H>>,
}

#[cfg(feature = "bench")]
impl<H: StarkHash + Send + Sync, DB: BonsaiDatabase + Clone, CommitID: Id> Clone
for MerkleTrees<H, DB, CommitID>
{
Expand Down Expand Up @@ -268,6 +269,7 @@ pub struct MerkleTree<H: StarkHash> {
}

// NB: #[derive(Clone)] does not work because it expands to an impl block which forces H: Clone, which Pedersen/Poseidon aren't.
#[cfg(feature = "bench")]
impl<H: StarkHash> Clone for MerkleTree<H> {
fn clone(&self) -> Self {
Self {
Expand Down

0 comments on commit af3d8a8

Please sign in to comment.