mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
bfc9dc447f
We currently have 2 base64 coders: one in AK, another in LibWeb for a "forgiving" implementation. ECMA-262 has an upcoming proposal which will require a third implementation. Instead, let's use the base64 implementation that is used by Node.js and recommended by the upcoming proposal. It handles forgiving decoding as well. Our users of AK's implementation should be fine with the forgiving implementation. The AK impl originally had naive forgiving behavior, but that was removed solely for performance reasons. Using http://mattmahoney.net/dc/enwik8.zip (100MB unzipped) as a test, performance of our old home-grown implementations vs. the simdutf implementation (on Linux x64): Encode Decode AK base64 0.226s 0.169s LibWeb base64 N/A 1.244s simdutf 0.161s 0.047s
29 lines
574 B
C++
29 lines
574 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
#include <AK/Error.h>
|
|
#include <AK/String.h>
|
|
#include <AK/StringView.h>
|
|
|
|
namespace AK {
|
|
|
|
ErrorOr<ByteBuffer> decode_base64(StringView);
|
|
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
|
|
|
ErrorOr<String> encode_base64(ReadonlyBytes);
|
|
ErrorOr<String> encode_base64url(ReadonlyBytes);
|
|
|
|
}
|
|
|
|
#if USING_AK_GLOBALLY
|
|
using AK::decode_base64;
|
|
using AK::decode_base64url;
|
|
using AK::encode_base64;
|
|
using AK::encode_base64url;
|
|
#endif
|