Skip to content

Commit 5957e7a

Browse files
committed
Reduce uncovered zero-initializer lines on cpp_int_backend::do_assign_string
1 parent 4d55021 commit 5957e7a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

include/boost/multiprecision/cpp_int.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,12 +1906,11 @@ struct cpp_int_backend
19061906
++s;
19071907
std::size_t bitcount = 4 * detail::constexpr_strlen(s);
19081908
limb_type val = 0;
1909-
std::size_t limb = 0, shift = 0;
19101909
if (bitcount > 4)
19111910
bitcount -= 4;
19121911
else
19131912
bitcount = 0;
1914-
std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1;
1913+
const std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1;
19151914
result.resize(static_cast<unsigned>(newsize), static_cast<unsigned>(newsize)); // will throw if this is a checked integer that cannot be resized
19161915
detail::constexpr_zero_trivial(result.limbs(), result.size());
19171916
while (*s)
@@ -1930,8 +1929,8 @@ struct cpp_int_backend
19301929

19311930
BOOST_MP_THROW_EXCEPTION(std::runtime_error("Unexpected content found while parsing character string."));
19321931
}
1933-
limb = bitcount / (sizeof(limb_type) * CHAR_BIT);
1934-
shift = bitcount % (sizeof(limb_type) * CHAR_BIT);
1932+
const std::size_t limb = bitcount / (sizeof(limb_type) * CHAR_BIT);
1933+
const std::size_t shift = bitcount % (sizeof(limb_type) * CHAR_BIT);
19351934
val <<= shift;
19361935
if (result.size() > limb)
19371936
{
@@ -1948,12 +1947,11 @@ struct cpp_int_backend
19481947
++s;
19491948
std::size_t bitcount = 3 * detail::constexpr_strlen(s);
19501949
limb_type val = 0;
1951-
std::size_t limb = 0, shift = 0;
19521950
if (bitcount > 3)
19531951
bitcount -= 3;
19541952
else
19551953
bitcount = 0;
1956-
std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1;
1954+
const std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1;
19571955
result.resize(static_cast<unsigned>(newsize), static_cast<unsigned>(newsize)); // will throw if this is a checked integer that cannot be resized
19581956
detail::constexpr_zero_trivial(result.limbs(), result.size());
19591957
while (*s)
@@ -1968,8 +1966,8 @@ struct cpp_int_backend
19681966

19691967
BOOST_MP_THROW_EXCEPTION(std::runtime_error("Unexpected content found while parsing character string."));
19701968
}
1971-
limb = bitcount / (sizeof(limb_type) * CHAR_BIT);
1972-
shift = bitcount % (sizeof(limb_type) * CHAR_BIT);
1969+
const std::size_t limb = bitcount / (sizeof(limb_type) * CHAR_BIT);
1970+
const std::size_t shift = bitcount % (sizeof(limb_type) * CHAR_BIT);
19731971
if (result.size() > limb)
19741972
{
19751973
result.limbs()[limb] |= (val << shift);

0 commit comments

Comments
 (0)