diff --git a/src/crackcodes.hpp b/src/crackcodes.hpp index 532b682..bbc8c2d 100644 --- a/src/crackcodes.hpp +++ b/src/crackcodes.hpp @@ -624,18 +624,17 @@ std::vector unpack_codepoints( std::vector codepoints; codepoints.reserve(4 * (code.size() - index_size)); + uint8_t last = 0; + for (uint64_t i = index_size; i < code.size(); i++) { for (uint64_t j = 0; j < 4; j++) { uint8_t codepoint = static_cast((code[i] >> (2*j)) & 0b11); + codepoint += last; + codepoint &= 0b11; + last = codepoint; codepoints.push_back(codepoint); } } - for (uint64_t i = 1; i < codepoints.size(); i++) { - codepoints[i] += codepoints[i-1]; - if (codepoints[i] > 3) { - codepoints[i] -= 4; - } - } return codepoints; }