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