From dbc2b5c5854f11402d1048508e53b6df7109a18b Mon Sep 17 00:00:00 2001 From: Vladimir Petrzhikovskii Date: Thu, 16 Apr 2026 21:50:39 +0200 Subject: [PATCH] don't merge test --- src/util.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util.rs b/src/util.rs index 8667f34dca..aaf2e16bad 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,30 +3,24 @@ pub(crate) use core::intrinsics::{likely, unlikely}; #[cfg(not(feature = "nightly"))] -#[inline(always)] -#[cold] -fn cold_path() {} +use core::hint::cold_path; #[cfg(not(feature = "nightly"))] #[inline(always)] -pub(crate) fn likely(b: bool) -> bool { - if b { - true - } else { +pub const fn likely(b: bool) -> bool { + if !b { cold_path(); - false } + b } #[cfg(not(feature = "nightly"))] #[inline(always)] -pub(crate) fn unlikely(b: bool) -> bool { +pub const fn unlikely(b: bool) -> bool { if b { cold_path(); - true - } else { - false } + b } // FIXME: use strict provenance functions once they are stable.