Skip to content

Commit

Permalink
chore: remove unused Default requirement in Table generics (parad…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Feb 12, 2024
1 parent f2f1f09 commit 17eca36
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions crates/storage/db/benches/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn serialization(c: &mut Criterion) {
/// Measures `Encode`, `Decode`, `Compress` and `Decompress`.
fn measure_table_serialization<T>(group: &mut BenchmarkGroup<'_, WallTime>)
where
T: Table + Default,
T: Table,
T::Key: Default + Clone + for<'de> serde::Deserialize<'de>,
T::Value: Default + Clone + for<'de> serde::Deserialize<'de>,
{
Expand Down Expand Up @@ -119,7 +119,7 @@ where
/// Measures `SeqWrite`, `RandomWrite`, `SeqRead` and `RandomRead` using `cursor` and `tx.put`.
fn measure_table_db<T>(group: &mut BenchmarkGroup<'_, WallTime>)
where
T: Table + Default,
T: Table,
T::Key: Default + Clone + for<'de> serde::Deserialize<'de>,
T::Value: Default + Clone + for<'de> serde::Deserialize<'de>,
{
Expand Down Expand Up @@ -215,7 +215,7 @@ where
/// Measures `SeqWrite`, `RandomWrite` and `SeqRead` using `cursor_dup` and `tx.put`.
fn measure_dupsort_db<T>(group: &mut BenchmarkGroup<'_, WallTime>)
where
T: Table + Default + DupSort,
T: Table + DupSort,
T::Key: Default + Clone + for<'de> serde::Deserialize<'de>,
T::Value: Default + Clone + for<'de> serde::Deserialize<'de>,
T::SubKey: Default + Clone + for<'de> serde::Deserialize<'de>,
Expand Down
12 changes: 6 additions & 6 deletions crates/storage/db/benches/hash_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn hash_keys(c: &mut Criterion) {

fn measure_table_insertion<T>(group: &mut BenchmarkGroup<'_, WallTime>, size: usize)
where
T: Table + Default,
T: Table,
T::Key: Default
+ Clone
+ for<'de> serde::Deserialize<'de>
Expand Down Expand Up @@ -132,7 +132,7 @@ where
#[allow(clippy::type_complexity)]
fn generate_batches<T>(size: usize) -> (Vec<TableRow<T>>, Vec<TableRow<T>>)
where
T: Table + Default,
T: Table,
T::Key: std::hash::Hash + Arbitrary,
T::Value: Arbitrary,
{
Expand All @@ -159,7 +159,7 @@ where

fn append<T>(db: DatabaseEnv, input: Vec<(<T as Table>::Key, <T as Table>::Value)>) -> DatabaseEnv
where
T: Table + Default,
T: Table,
{
{
let tx = db.tx_mut().expect("tx");
Expand All @@ -177,7 +177,7 @@ where

fn insert<T>(db: DatabaseEnv, input: Vec<(<T as Table>::Key, <T as Table>::Value)>) -> DatabaseEnv
where
T: Table + Default,
T: Table,
{
{
let tx = db.tx_mut().expect("tx");
Expand All @@ -195,7 +195,7 @@ where

fn put<T>(db: DatabaseEnv, input: Vec<(<T as Table>::Key, <T as Table>::Value)>) -> DatabaseEnv
where
T: Table + Default,
T: Table,
{
{
let tx = db.tx_mut().expect("tx");
Expand Down Expand Up @@ -223,7 +223,7 @@ struct TableStats {

fn get_table_stats<T>(db: DatabaseEnv)
where
T: Table + Default,
T: Table,
{
db.view(|tx| {
let table_db = tx.inner.open_db(Some(T::NAME)).map_err(|_| "Could not open db.").unwrap();
Expand Down
3 changes: 1 addition & 2 deletions crates/storage/db/benches/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const RANDOM_INDEXES: [usize; 10] = [23, 2, 42, 5, 3, 99, 54, 0, 33, 64];
#[allow(dead_code)]
pub(crate) fn load_vectors<T: Table>() -> Vec<(T::Key, Bytes, T::Value, Bytes)>
where
T: Default,
T::Key: Default + Clone + for<'de> serde::Deserialize<'de>,
T::Value: Default + Clone + for<'de> serde::Deserialize<'de>,
{
Expand Down Expand Up @@ -54,7 +53,7 @@ pub(crate) fn set_up_db<T>(
pair: &Vec<(<T as Table>::Key, Bytes, <T as Table>::Value, Bytes)>,
) -> DatabaseEnv
where
T: Table + Default,
T: Table,
T::Key: Default + Clone,
T::Value: Default + Clone,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db/src/implementation/mdbx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl DatabaseMetrics for DatabaseEnv {

let _ = self
.view(|tx| {
for table in Tables::ALL.iter().map(|table| table.name()) {
for table in Tables::ALL.iter().map(Tables::name) {
let table_db = tx.inner.open_db(Some(table)).wrap_err("Could not open db.")?;

let stats = tx
Expand Down

0 comments on commit 17eca36

Please sign in to comment.