ReneNyffenegger / cpp-base64

base64 encoding and decoding with c++
Other
891 stars 311 forks source link

Use a lookup table for decoding #43

Closed heifner closed 1 year ago

heifner commented 1 year ago

According to "measure_time.cpp" benchmark, decoding is 2.55 (g++ -O3) / 2.65 (g++ -O0) times slower than encoding. One of the bottleneck comes from doing several comparisons and calculating the value for each decoded character. Replacing the comparison + calculation by a lookup table (like in the encoding) improves the decoding speed, making it only 2.22 (g++ -O0) / 1.36 (g++ -O2) times slower than encoding.

Cherry-picked from: https://github.com/ReneNyffenegger/cpp-base64/pull/27