Skip to content

Conversation

@alexggh
Copy link
Contributor

@alexggh alexggh commented Jul 8, 2025

To be used by paritytech/polkadot-sdk#9127, to replace the default hasher with a custom one.

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@bkchr
Copy link
Member

bkchr commented Jul 8, 2025

@alexggh you should directly bump the crate version.

Comment on lines 245 to 250
impl<H, KF, T, S> Default for MemoryDB<H, KF, T, S>
where
H: KeyHasher,
T: for<'a> From<&'a [u8]>,
KF: KeyFunction<H>,
S: BuildHasher + Default,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl<H, KF, T, S> Default for MemoryDB<H, KF, T, S>
where
H: KeyHasher,
T: for<'a> From<&'a [u8]>,
KF: KeyFunction<H>,
S: BuildHasher + Default,
impl<H, KF, T> Default for MemoryDB<H, KF, T, RandomState>
where
H: KeyHasher,
T: for<'a> From<&'a [u8]>,
KF: KeyFunction<H>,

This way you can just use default() without declaring the random state. Similar to HashMap we should then provide a function with_random_state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, specialising the default meant that I had to plumb a few places where default() did not work anymore when using it with the custom RandomState.

But, I like that more since it is similar with how hashmap is used.

alexggh added 2 commits July 8, 2025 16:23
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh
Copy link
Contributor Author

alexggh commented Jul 8, 2025

@alexggh you should directly bump the crate version.

Done.

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh alexggh merged commit 0f30619 into master Jul 11, 2025
4 checks passed
alexggh added a commit that referenced this pull request Jul 11, 2025
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
alexggh added a commit that referenced this pull request Jul 11, 2025
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants