diff --git a/src/branching.rs b/src/branching.rs index f5a84ea..5cad16e 100644 --- a/src/branching.rs +++ b/src/branching.rs @@ -18,3 +18,23 @@ macro_rules! invoke_once { } } +pub struct OnDrop(Option); + +impl OnDrop { + pub fn new(fun: F) -> Self { + Self(Some(fun)) + } +} + +impl Drop for OnDrop { + fn drop(&mut self) { + if let Some(fun) = self.0.take() { + fun() + } + } +} + + + + + diff --git a/src/hash.rs b/src/hash.rs index af6de34..348fcdb 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -26,6 +26,7 @@ pub const fn hash32(bytes: &[u32]) -> u64 { } //noinspection DuplicatedCode +#[inline(always)] pub const fn hash64(bytes: &[u64]) -> u64 { let mut hash = INITIAL_STATE; let mut i = 0; @@ -38,6 +39,7 @@ pub const fn hash64(bytes: &[u64]) -> u64 { } //noinspection DuplicatedCode +#[inline(always)] pub const fn hash_utf8(bytes: &[u8]) -> u64 { let mut hash = INITIAL_STATE; let mut i = 0;