core: improve comments

Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com>
Co-authored-by: Hanna Kruppe <hanna.kruppe@gmail.com>
This commit is contained in:
Jonas Böttiger
2024-12-09 13:22:39 +01:00
committed by GitHub
parent 69942f0132
commit 13c77ba34d

View File

@@ -62,12 +62,14 @@ impl bool {
} }
/// Returns either `true_val` or `false_val` depending on the value of /// Returns either `true_val` or `false_val` depending on the value of
/// `condition`, with a hint to the compiler that `condition` is unlikely /// `self`, with a hint to the compiler that `self` is unlikely
/// to be correctly predicted by a CPUs branch predictor. /// to be correctly predicted by a CPUs branch predictor.
/// ///
/// This method is functionally equivalent to writing /// This method is functionally equivalent to
/// ```ignore (this is just for illustrative purposes) /// ```ignore (this is just for illustrative purposes)
/// fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
/// if b { true_val } else { false_val } /// if b { true_val } else { false_val }
/// }
/// ``` /// ```
/// but might generate different assembly. In particular, on platforms with /// but might generate different assembly. In particular, on platforms with
/// a conditional move or select instruction (like `cmov` on x86 or `csel` /// a conditional move or select instruction (like `cmov` on x86 or `csel`