-
Notifications
You must be signed in to change notification settings - Fork 287
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
Further sequester Group
/Tag
code
#568
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,35 @@ | |||
cfg_if! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just copied directly from the raw
module, without any additional changes.
src/control/tag.rs
Outdated
/// Extension trait for slices of tags. | ||
pub(crate) trait TagSliceExt { | ||
/// Fills the control with the given tag. | ||
fn fill_tag(&mut self, tag: Tag); | ||
|
||
/// Clears out the control. | ||
fn fill_empty(&mut self) { | ||
self.fill_tag(Tag::EMPTY) | ||
} | ||
} | ||
impl TagSliceExt for [Tag] { | ||
fn fill_tag(&mut self, tag: Tag) { | ||
// SAFETY: We have access to the entire slice, so, we can write to the entire slice. | ||
unsafe { self.as_mut_ptr().write_bytes(tag.0, self.len()) } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new code.
The TagSliceExt
was a mostly impulse decision to be able to do slice.fill_empty()
instead of Tag::EMPTY.fill(slice)
, and since it's solely an internal API anyway it isn't a big deal. The most import part is that this lets us make the inside of a tag private relative to the raw
module.
We're not able to just do slice.fill(Tag::EMPTY)
and have it optimise into memset by itself, which is why this exists.
impl fmt::Debug for Tag { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
if self.is_special() { | ||
if self.special_is_empty() { | ||
f.pad("EMPTY") | ||
} else { | ||
f.pad("DELETED") | ||
} | ||
} else { | ||
f.debug_tuple("full").field(&(self.0 & 0x7F)).finish() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to replace the derived debug to help me debug the code I'm going to add in a future PR, so it's a bit easier to read. I figure that if we care about the additional compile time added by this one debug impl so much we can cfg(debug_assertions)
gate it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a problem for compilation time since it's not a generic function.
@@ -0,0 +1,14 @@ | |||
// FIXME: Branch prediction hint. This is currently only available on nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't feeling particularly creative and will need this in the control
module too in the future, so, I decided to separate them into their own module.
Maybe nightly
would be a better name, but I don't think it matters that much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually broken at the moment on nightly until rust-lang/rust#120370 is merged, so it doesn't even do anything. But it's probably fine to keep for now as a reminder to fix this later.
☔ The latest upstream changes (presumably #572) made this pull request unmergeable. Please resolve the merge conflicts. |
3df96dd
to
11f2cf9
Compare
@@ -102,7 +102,7 @@ impl IntoIterator for BitMask { | |||
|
|||
/// Iterator over the contents of a `BitMask`, returning the indices of set | |||
/// bits. | |||
#[derive(Copy, Clone)] | |||
#[derive(Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterators in general shouldn't implement Copy
, for better or worse.
11f2cf9
to
f7aa64a
Compare
So, I figured out why my probing logic wasn't working: it wasn't because it wasn't working, but because my debug-assert checking that it was working wasn't working, and giving me false positives. So, #578 exists to demonstrate the fuller version of the control module so you can get an idea where I'm coming from with this change, even though this should be merged first. |
} | ||
} | ||
impl TagSliceExt for [Tag] { | ||
fn fill_tag(&mut self, tag: Tag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs #[inline]
.
fn fill_tag(&mut self, tag: Tag); | ||
|
||
/// Clears out the control. | ||
fn fill_empty(&mut self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs #[inline]
.
impl fmt::Debug for Tag { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
if self.is_special() { | ||
if self.special_is_empty() { | ||
f.pad("EMPTY") | ||
} else { | ||
f.pad("DELETED") | ||
} | ||
} else { | ||
f.debug_tuple("full").field(&(self.0 & 0x7F)).finish() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a problem for compilation time since it's not a generic function.
@@ -0,0 +1,14 @@ | |||
// FIXME: Branch prediction hint. This is currently only available on nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually broken at the moment on nightly until rust-lang/rust#120370 is merged, so it doesn't even do anything. But it's probably fine to keep for now as a reminder to fix this later.
f7aa64a
to
4f75078
Compare
Was originally going to make this part of a larger change, but decided this bit is enough for its own PR.
Essentially, this completely moves the
Group
andTag
code outside of theraw
module into a separatecontrol
module. This module will also eventually be the future home for stuff likeRawIterHash
andProbeSeq
, but I decided that that would be better as a separate PR, since moving and modifying the files makes it harder to review.