This is my treatment of @kallewoof's #13586
I got another big win out of not catting together the values and checksum for iteration, and a small win from using pre-increment.
This results in a ~40% speed-up in calls to Encode()
Before:
#Benchmark, evals, iterations, total, min, max, median
Bech32Encode, 5, 800000, 5.98941, 1.46948e-06, 1.56082e-06, 1.49065e-06
After:
#Benchmark, evals, iterations, total, min, max, median
Bech32Encode, 5, 800000, 3.60337, 8.82574e-07, 9.23948e-07, 8.93568e-07
Also throwing a std::length_error on length error, rather than asserting, for easier error handling.
This PR brought to you by insomnia.