Skip to content

Commit

Permalink
Remove backup implementation of likely/unlikely that didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed May 31, 2023
1 parent 4d8c059 commit d677fd4
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,12 @@ use self::imp::Group;

// Branch prediction hint. This is currently only available on nightly but it
// consistently improves performance by 10-15%.
#[cfg(feature = "nightly")]
use core::intrinsics::{likely, unlikely};

// On stable we can use #[cold] to get a equivalent effect: this attributes
// suggests that the function is unlikely to be called
#[cfg(not(feature = "nightly"))]
#[inline]
#[cold]
fn cold() {}

#[cfg(not(feature = "nightly"))]
#[inline]
fn likely(b: bool) -> bool {
if !b {
cold();
}
b
}
use core::convert::identity as likely;
#[cfg(not(feature = "nightly"))]
#[inline]
fn unlikely(b: bool) -> bool {
if b {
cold();
}
b
}
use core::convert::identity as unlikely;
#[cfg(feature = "nightly")]
use core::intrinsics::{likely, unlikely};

// Use strict provenance functions if available.
#[cfg(feature = "nightly")]
Expand Down

0 comments on commit d677fd4

Please sign in to comment.