Skip to content

Commit

Permalink
Move probing logic to control module
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed Nov 13, 2024
1 parent b74e3a7 commit 262899b
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 503 deletions.
9 changes: 6 additions & 3 deletions src/control/group/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,23 @@ impl Group {
/// Number of bytes in the group.
pub(crate) const WIDTH: usize = mem::size_of::<Self>();

/// Double the group width; size of [`Group::static_empty`].
pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2;

/// Returns a full group of empty tags, suitable for use as the initial
/// value for an empty hash table.
///
/// This is guaranteed to be aligned to the group size.
#[inline]
pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] {
pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] {
#[repr(C)]
struct AlignedTags {
_align: [Group; 0],
tags: [Tag; Group::WIDTH],
tags: [Tag; Group::DOUBLE_WIDTH],
}
const ALIGNED_TAGS: AlignedTags = AlignedTags {
_align: [],
tags: [Tag::EMPTY; Group::WIDTH],
tags: [Tag::EMPTY; Group::DOUBLE_WIDTH],
};
&ALIGNED_TAGS.tags
}
Expand Down
9 changes: 6 additions & 3 deletions src/control/group/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ impl Group {
/// Number of bytes in the group.
pub(crate) const WIDTH: usize = mem::size_of::<Self>();

/// Double the group width; size of [`Group::static_empty`].
pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2;

/// Returns a full group of empty tags, suitable for use as the initial
/// value for an empty hash table.
///
/// This is guaranteed to be aligned to the group size.
#[inline]
pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] {
pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] {
#[repr(C)]
struct AlignedTags {
_align: [Group; 0],
tags: [Tag; Group::WIDTH],
tags: [Tag; Group::DOUBLE_WIDTH],
}
const ALIGNED_TAGS: AlignedTags = AlignedTags {
_align: [],
tags: [Tag::EMPTY; Group::WIDTH],
tags: [Tag::EMPTY; Group::DOUBLE_WIDTH],
};
&ALIGNED_TAGS.tags
}
Expand Down
9 changes: 6 additions & 3 deletions src/control/group/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ impl Group {
/// Number of bytes in the group.
pub(crate) const WIDTH: usize = mem::size_of::<Self>();

/// Double the group width; size of [`Group::static_empty`].
pub(crate) const DOUBLE_WIDTH: usize = Group::WIDTH * 2;

/// Returns a full group of empty tags, suitable for use as the initial
/// value for an empty hash table.
///
/// This is guaranteed to be aligned to the group size.
#[inline]
#[allow(clippy::items_after_statements)]
pub(crate) const fn static_empty() -> &'static [Tag; Group::WIDTH] {
pub(crate) const fn static_empty() -> &'static [Tag; Group::DOUBLE_WIDTH] {
#[repr(C)]
struct AlignedTags {
_align: [Group; 0],
tags: [Tag; Group::WIDTH],
tags: [Tag; Group::DOUBLE_WIDTH],
}
const ALIGNED_TAGS: AlignedTags = AlignedTags {
_align: [],
tags: [Tag::EMPTY; Group::WIDTH],
tags: [Tag::EMPTY; Group::DOUBLE_WIDTH],
};
&ALIGNED_TAGS.tags
}
Expand Down
2 changes: 2 additions & 0 deletions src/control/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod bitmask;
mod group;
mod probe;
mod tag;

use self::bitmask::BitMask;
pub(crate) use self::{
bitmask::BitMaskIter,
group::Group,
probe::{Probe, ProbeItems},
tag::{Tag, TagSliceExt},
};
Loading

0 comments on commit 262899b

Please sign in to comment.