solar_data_structures/hint.rs
1#[inline(always)]
2#[cfg_attr(not(feature = "nightly"), cold)]
3pub const fn cold_path() {
4 #[cfg(feature = "nightly")]
5 core::intrinsics::cold_path();
6}
7
8#[inline(always)]
9pub const fn likely(b: bool) -> bool {
10 #[cfg(feature = "nightly")]
11 return core::intrinsics::likely(b);
12
13 #[cfg(not(feature = "nightly"))]
14 if b {
15 true
16 } else {
17 cold_path();
18 false
19 }
20}
21
22#[inline(always)]
23pub const fn unlikely(b: bool) -> bool {
24 #[cfg(feature = "nightly")]
25 return core::intrinsics::unlikely(b);
26
27 #[cfg(not(feature = "nightly"))]
28 if b {
29 cold_path();
30 true
31 } else {
32 false
33 }
34}