Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move probing logic into control module #578

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading