1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

Everywhere: Pass AK::StringView by value

This commit is contained in:
Andreas Kling 2021-11-11 00:55:02 +01:00
parent ad5d217e76
commit 8b1108e485
Notes: sideshowbarker 2024-07-18 01:17:49 +09:00
392 changed files with 978 additions and 978 deletions

View file

@ -192,21 +192,21 @@ Optional<String> get_standardized_encoding(const String& encoding)
return {};
}
String Decoder::to_utf8(const StringView& input)
String Decoder::to_utf8(StringView input)
{
StringBuilder builder(input.length());
process(input, [&builder](u32 c) { builder.append_code_point(c); });
return builder.to_string();
}
void UTF8Decoder::process(const StringView& input, Function<void(u32)> on_code_point)
void UTF8Decoder::process(StringView input, Function<void(u32)> on_code_point)
{
for (auto c : input) {
on_code_point(c);
}
}
String UTF8Decoder::to_utf8(const StringView& input)
String UTF8Decoder::to_utf8(StringView input)
{
// Discard the BOM
auto bomless_input = input;
@ -217,7 +217,7 @@ String UTF8Decoder::to_utf8(const StringView& input)
return bomless_input;
}
void UTF16BEDecoder::process(const StringView& input, Function<void(u32)> on_code_point)
void UTF16BEDecoder::process(StringView input, Function<void(u32)> on_code_point)
{
size_t utf16_length = input.length() - (input.length() % 2);
for (size_t i = 0; i < utf16_length; i += 2) {
@ -226,7 +226,7 @@ void UTF16BEDecoder::process(const StringView& input, Function<void(u32)> on_cod
}
}
String UTF16BEDecoder::to_utf8(const StringView& input)
String UTF16BEDecoder::to_utf8(StringView input)
{
// Discard the BOM
auto bomless_input = input;
@ -239,7 +239,7 @@ String UTF16BEDecoder::to_utf8(const StringView& input)
return builder.to_string();
}
void Latin1Decoder::process(const StringView& input, Function<void(u32)> on_code_point)
void Latin1Decoder::process(StringView input, Function<void(u32)> on_code_point)
{
for (size_t i = 0; i < input.length(); ++i) {
u8 ch = input[i];
@ -327,14 +327,14 @@ u32 convert_latin2_to_utf8(u8 in)
}
}
void Latin2Decoder::process(const StringView& input, Function<void(u32)> on_code_point)
void Latin2Decoder::process(StringView input, Function<void(u32)> on_code_point)
{
for (auto c : input) {
on_code_point(convert_latin2_to_utf8(c));
}
}
void HebrewDecoder::process(const StringView& input, Function<void(u32)> on_code_point)
void HebrewDecoder::process(StringView input, Function<void(u32)> on_code_point)
{
static constexpr Array<u32, 128> translation_table = {
0x20AC, 0xFFFD, 0x201A, 0x192, 0x201E, 0x2026, 0x2020, 0x2021, 0x2C6, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
@ -355,7 +355,7 @@ void HebrewDecoder::process(const StringView& input, Function<void(u32)> on_code
}
}
void CyrillicDecoder::process(const StringView& input, Function<void(u32)> on_code_point)
void CyrillicDecoder::process(StringView input, Function<void(u32)> on_code_point)
{
static constexpr Array<u32, 128> translation_table = {
0x402, 0x403, 0x201A, 0x453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, 0x409, 0x2039, 0x40A, 0x40C, 0x40B, 0x40F,
@ -376,7 +376,7 @@ void CyrillicDecoder::process(const StringView& input, Function<void(u32)> on_co
}
}
void Latin9Decoder::process(const StringView& input, Function<void(u32)> on_code_point)
void Latin9Decoder::process(StringView input, Function<void(u32)> on_code_point)
{
auto convert_latin9_to_utf8 = [](u8 ch) -> u32 {
// Latin9 is the same as the first 256 Unicode code points, except for 8 characters.
@ -407,7 +407,7 @@ void Latin9Decoder::process(const StringView& input, Function<void(u32)> on_code
}
}
void TurkishDecoder::process(const StringView& input, Function<void(u32)> on_code_point)
void TurkishDecoder::process(StringView input, Function<void(u32)> on_code_point)
{
auto convert_turkish_to_utf8 = [](u8 ch) -> u32 {
// Turkish (aka ISO-8859-9, Windows-1254) is the same as the first 256 Unicode code points, except for 6 characters.