Optimize SbTag::eq
The code before generated really bad code with a branch. This nudges LLVM towards being smarter and simply comparing the integers.
This commit is contained in:
parent
b8d5ee037b
commit
956a84bfe0
@ -27,12 +27,27 @@
|
||||
pub type AllocExtra = Stacks;
|
||||
|
||||
/// Tracking pointer provenance
|
||||
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Hash, Eq)]
|
||||
pub enum SbTag {
|
||||
Tagged(PtrId),
|
||||
Untagged,
|
||||
}
|
||||
|
||||
impl SbTag {
|
||||
fn as_u64(self) -> u64 {
|
||||
match self {
|
||||
SbTag::Tagged(id) => id.get(),
|
||||
SbTag::Untagged => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for SbTag {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.as_u64() == other.as_u64()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for SbTag {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
Loading…
Reference in New Issue
Block a user