AK: Do not perform UTF-8 validation on Base64-encoded strings

We know we are only appending ASCII characters to the StringBuilder, so
do not bother validating the result.

This reduces the runtime of `./bin/base64 enwik8 >/dev/null` from
1.192s to 0.976s.

(enwik8 is a 100MB test file from http://mattmahoney.net/dc/enwik8.zip)
This commit is contained in:
Timothy Flynn 2024-03-20 11:11:20 -04:00 committed by Andreas Kling
parent d6884a5d6f
commit 5f5b8ee9bb
Notes: sideshowbarker 2024-07-17 04:49:48 +09:00

View file

@ -117,7 +117,7 @@ ErrorOr<String> encode_base64_impl(ReadonlyBytes input)
TRY(output.try_append(out3));
}
return output.to_string();
return output.to_string_without_validation();
}
ErrorOr<ByteBuffer> decode_base64(StringView input)