AK: Use calculate_base64_encoded_length in encode_base64

We were accidentally calling calculate_base64_decoded_length instead,
which resulted in extra allocations during the StringBuilder::append
calls that can be avoided.
This commit is contained in:
Idan Horowitz 2021-05-22 02:38:44 +03:00 committed by Ali Mohammad Pur
parent 155d876c44
commit 3bc3a7a23a

View file

@ -96,7 +96,7 @@ ByteBuffer decode_base64(const StringView& input)
String encode_base64(ReadonlyBytes input)
{
constexpr auto alphabet = make_alphabet();
StringBuilder output(calculate_base64_decoded_length(input));
StringBuilder output(calculate_base64_encoded_length(input));
auto get = [&](const size_t offset, bool* need_padding = nullptr) -> u8 {
if (offset >= input.size()) {