diff --git a/include/duckhandy/implem/int_conv.hpp b/include/duckhandy/implem/int_conv.hpp index ded9174..2fd9239 100644 --- a/include/duckhandy/implem/int_conv.hpp +++ b/include/duckhandy/implem/int_conv.hpp @@ -159,14 +159,6 @@ namespace dhandy { using RetType = RevArray; using Num = implem::NumberAdaptation; - //How to build this lookup: 1) write numbers 0, 10, 20..., 90 - //in binary; 2) take the lowest 5 bits, div by 2 and write as - //decimal; 3) divide by 2; 4) the result is the position in the - //below array that should be filled in with the leading digit - //from the original 0-90 number - constexpr const char lookup[16] = { - 0, 0, 0, 7, 4, 1, 0, 0, 8, 5, 2, 0, 0, 9, 6, 3 - }; const bool was_negative = implem::is_negative(in); RetType arr; @@ -178,7 +170,7 @@ namespace dhandy { const auto last_two = in % 100; const auto digit_low = in % 10; in = static_cast(in / static_cast(100)); - const auto digit_high = lookup[((last_two - digit_low) >> 1) & 0xF]; + const auto digit_high = last_two / 10; arr.push_front(Tr::to_digit(static_cast(digit_low))); arr.push_front(Tr::to_digit(static_cast(digit_high))); }; @@ -187,7 +179,7 @@ namespace dhandy { } else { const auto digit_low = in % 10; - const auto digit_high = lookup[((in - digit_low) >> 1) & 0xF]; + const auto digit_high = (in / 10) % 10; arr.push_front(Tr::to_digit(static_cast(digit_low))); arr.push_front(Tr::to_digit(static_cast(digit_high))); } diff --git a/speed_test_int_conv.cpp b/speed_test_int_conv.cpp index d62c945..063ce95 100644 --- a/speed_test_int_conv.cpp +++ b/speed_test_int_conv.cpp @@ -33,7 +33,7 @@ void run_with_timing ( int main() { using dhandy::int_conv; - constexpr const std::size_t count = 50'000'000; + constexpr const std::size_t count = 70'000'000; std::vector nums; std::vector strings;