diff --git a/src/raw/mod.rs b/src/raw/mod.rs index e3da8714f5..3b667fd44d 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -43,14 +43,24 @@ use self::imp::Group; // 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 } #[cfg(not(feature = "nightly"))] #[inline] fn unlikely(b: bool) -> bool { + if b { cold() } b }