/rust/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.15.5/src/util.rs
Line | Count | Source (jump to first uncovered line) |
1 | | // FIXME: Replace with `core::hint::{likely, unlikely}` once they are stable. |
2 | | #[cfg(feature = "nightly")] |
3 | | pub(crate) use core::intrinsics::{likely, unlikely}; |
4 | | |
5 | | #[cfg(not(feature = "nightly"))] |
6 | | #[inline(always)] |
7 | | #[cold] |
8 | 512k | fn cold_path() {} |
9 | | |
10 | | #[cfg(not(feature = "nightly"))] |
11 | | #[inline(always)] |
12 | 10.0M | pub(crate) fn likely(b: bool) -> bool { |
13 | 10.0M | if b { |
14 | 9.94M | true |
15 | | } else { |
16 | 132k | cold_path(); |
17 | 132k | false |
18 | | } |
19 | 10.0M | } |
20 | | |
21 | | #[cfg(not(feature = "nightly"))] |
22 | | #[inline(always)] |
23 | 6.89M | pub(crate) fn unlikely(b: bool) -> bool { |
24 | 6.89M | if b { |
25 | 380k | cold_path(); |
26 | 380k | true |
27 | | } else { |
28 | 6.51M | false |
29 | | } |
30 | 6.89M | } |
31 | | |
32 | | // FIXME: use strict provenance functions once they are stable. |
33 | | // Implement it with a transmute for now. |
34 | | #[inline(always)] |
35 | | #[allow(clippy::useless_transmute)] // clippy is wrong, cast and transmute are different here |
36 | 0 | pub(crate) fn invalid_mut<T>(addr: usize) -> *mut T { |
37 | 0 | unsafe { core::mem::transmute(addr) } |
38 | 0 | } |