summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTextCodec
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-11 00:55:02 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-11 01:27:46 +0100
commit8b1108e4858f797c9216dc8ae4a3918ad50c73b4 (patch)
treeca64ba25aa735d25013d76c6d83570496c742014 /Userland/Libraries/LibTextCodec
parentad5d217e760c7fb73ffc0c4c827d767d6be8ec80 (diff)
downloadserenity-8b1108e4858f797c9216dc8ae4a3918ad50c73b4.zip
Everywhere: Pass AK::StringView by value
Diffstat (limited to 'Userland/Libraries/LibTextCodec')
-rw-r--r--Userland/Libraries/LibTextCodec/Decoder.cpp22
-rw-r--r--Userland/Libraries/LibTextCodec/Decoder.h24
2 files changed, 23 insertions, 23 deletions
diff --git a/Userland/Libraries/LibTextCodec/Decoder.cpp b/Userland/Libraries/LibTextCodec/Decoder.cpp
index 7a1bc03c01..b306ac1af2 100644
--- a/Userland/Libraries/LibTextCodec/Decoder.cpp
+++ b/Userland/Libraries/LibTextCodec/Decoder.cpp
@@ -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.
diff --git a/Userland/Libraries/LibTextCodec/Decoder.h b/Userland/Libraries/LibTextCodec/Decoder.h
index 6bbd515cb3..b1d0e2f429 100644
--- a/Userland/Libraries/LibTextCodec/Decoder.h
+++ b/Userland/Libraries/LibTextCodec/Decoder.h
@@ -13,8 +13,8 @@ namespace TextCodec {
class Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) = 0;
- virtual String to_utf8(StringView const&);
+ virtual void process(StringView, Function<void(u32)> on_code_point) = 0;
+ virtual String to_utf8(StringView);
protected:
virtual ~Decoder() = default;
@@ -22,44 +22,44 @@ protected:
class UTF8Decoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
- virtual String to_utf8(StringView const&) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
+ virtual String to_utf8(StringView) override;
};
class UTF16BEDecoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
- virtual String to_utf8(StringView const&) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
+ virtual String to_utf8(StringView) override;
};
class Latin1Decoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
class Latin2Decoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
class HebrewDecoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
class CyrillicDecoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
class Latin9Decoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
class TurkishDecoder final : public Decoder {
public:
- virtual void process(StringView const&, Function<void(u32)> on_code_point) override;
+ virtual void process(StringView, Function<void(u32)> on_code_point) override;
};
Decoder* decoder_for(String const& encoding);