mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +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
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…
Add table
Add a link
Reference in a new issue