Skip to content

Commit b1db3c5

Browse files
committed
Try pass by const ref
1 parent 46a0e3c commit b1db3c5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/boost/int128/numeric.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ inline uint128_t mul_sat<true>(const uint128_t x, const uint128_t y) noexcept
167167
}
168168

169169
template <bool = false>
170-
inline int128_t mul_sat(const int128_t x, const int128_t y) noexcept
170+
inline int128_t mul_sat(const int128_t& x, const int128_t& y) noexcept
171171
{
172172
const auto x_bits {bit_width(static_cast<uint128_t>(abs(x)))};
173173
const auto y_bits {bit_width(static_cast<uint128_t>(abs(y)))};
@@ -189,7 +189,7 @@ inline int128_t mul_sat(const int128_t x, const int128_t y) noexcept
189189
}
190190

191191
template <>
192-
inline int128_t mul_sat<true>(const int128_t x, const int128_t y) noexcept
192+
inline int128_t mul_sat<true>(const int128_t& x, const int128_t& y) noexcept
193193
{
194194
std::cerr << "Signed mul_sat" << std::endl;
195195

test/test_saturating_arith.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ void test_mul_sat<boost::int128::int128_t>()
402402

403403
while (bit_count < 254)
404404
{
405+
if (y > 0)
406+
{
407+
return;
408+
}
409+
405410
const boost::int128::int128_t sat_res {mul_sat(x, y)};
406411
if (!BOOST_TEST(sat_res == std::numeric_limits<boost::int128::int128_t>::min()))
407412
{

0 commit comments

Comments
 (0)