mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
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:
parent
155d876c44
commit
3bc3a7a23a
Notes:
sideshowbarker
2024-07-18 17:34:54 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/3bc3a7a23a9 Pull-request: https://github.com/SerenityOS/serenity/pull/7368
1 changed files with 1 additions and 1 deletions
|
@ -96,7 +96,7 @@ ByteBuffer decode_base64(const StringView& input)
|
||||||
String encode_base64(ReadonlyBytes input)
|
String encode_base64(ReadonlyBytes input)
|
||||||
{
|
{
|
||||||
constexpr auto alphabet = make_alphabet();
|
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 {
|
auto get = [&](const size_t offset, bool* need_padding = nullptr) -> u8 {
|
||||||
if (offset >= input.size()) {
|
if (offset >= input.size()) {
|
||||||
|
|
Loading…
Reference in a new issue