From 7d5ed3f00276605bb8cb26ca15c991600b3cb7bf Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 3 Mar 2026 05:57:54 +0000 Subject: [PATCH] Optimize inlining of math checked!() and expected!() predicates. Signed-off-by: Jason Volk --- src/core/utils/math.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/utils/math.rs b/src/core/utils/math.rs index 2e3e6b0c..b681a7f9 100644 --- a/src/core/utils/math.rs +++ b/src/core/utils/math.rs @@ -14,7 +14,12 @@ use crate::{Err, Error, Result, debug::type_name, err}; macro_rules! checked { ($($input:tt)+) => { $crate::utils::math::checked_ops!($($input)+) - .ok_or_else(|| $crate::err!(Arithmetic("operation overflowed or result invalid"))) + .ok_or_else( + // The compiler will now attempt to inline the math predicate + // while moving the error handling out to .text.unlikely. + #[cold] + || $crate::err!(Arithmetic("operation overflowed or result invalid")) + ) }; }