From 3bc3a7a23a96bf8a8f7bb46481dbbb4255435187 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 22 May 2021 02:38:44 +0300 Subject: [PATCH] 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. --- AK/Base64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/Base64.cpp b/AK/Base64.cpp index 5df2eebac9..906a608569 100644 --- a/AK/Base64.cpp +++ b/AK/Base64.cpp @@ -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()) {