/rust/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.41/src/hint.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! Hints to the compiler that affects how code should be emitted or optimized. |
2 | | |
3 | | #![allow(dead_code)] // may be used in the future and has minimal overhead |
4 | | |
5 | | /// Indicate that a given branch is **not** likely to be taken, relatively speaking. |
6 | | #[inline(always)] |
7 | | #[cold] |
8 | 0 | pub(crate) const fn cold_path() {} |
9 | | |
10 | | /// Indicate that a given condition is likely to be true. |
11 | | #[inline(always)] |
12 | 0 | pub(crate) const fn likely(b: bool) -> bool { |
13 | 0 | if !b { |
14 | 0 | cold_path(); |
15 | 0 | } |
16 | 0 | b |
17 | 0 | } |
18 | | |
19 | | /// Indicate that a given condition is likely to be false. |
20 | | #[inline(always)] |
21 | 0 | pub(crate) const fn unlikely(b: bool) -> bool { |
22 | 0 | if b { |
23 | 0 | cold_path(); |
24 | 0 | } |
25 | 0 | b |
26 | 0 | } |