Skip to content

Commit c4c0f6c

Browse files
committed
Make operator== branchless
1 parent a7675df commit c4c0f6c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,12 @@ constexpr auto isfinite(decimal32_fast val) noexcept -> bool
474474

475475
constexpr auto operator==(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
476476
{
477-
#ifndef BOOST_DECIMAL_FAST_MATH
478-
if (isnan(lhs) || isnan(rhs))
479-
{
480-
return false;
481-
}
482-
#endif
483-
484-
return (lhs.sign_ == rhs.sign_) &
485-
(lhs.exponent_ == rhs.exponent_) &
477+
return
478+
#ifndef BOOST_DECIMAL_FAST_MATH
479+
!isnan(lhs) && !isnan(rhs) &&
480+
#endif
481+
(lhs.sign_ == rhs.sign_) &&
482+
(lhs.exponent_ == rhs.exponent_) &&
486483
(lhs.significand_ == rhs.significand_);
487484
}
488485

0 commit comments

Comments
 (0)