diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-18 18:02:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-18 19:54:24 +0200 |
commit | 1be4cbd6395202183d7aa74119661aae71a8b8d9 (patch) | |
tree | f2593d9fee011da56f127b7583fba4eea4b8dd4e /AK | |
parent | 291dbff2e1dbd1963e07fdc92779b5c25e635127 (diff) | |
download | serenity-1be4cbd6395202183d7aa74119661aae71a8b8d9.zip |
AK: Make Utf8View constructors inline and remove C string constructor
Using StringView instead of C strings is basically always preferable.
The only reason to use a C string is because you are calling a C API.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Utf8View.cpp | 15 | ||||
-rw-r--r-- | AK/Utf8View.h | 15 |
2 files changed, 12 insertions, 18 deletions
diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index 4d2f5d62e1..8e4fdc23e0 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -11,21 +11,6 @@ namespace AK { -Utf8View::Utf8View(const String& string) - : m_string(string) -{ -} - -Utf8View::Utf8View(const StringView& string) - : m_string(string) -{ -} - -Utf8View::Utf8View(const char* string) - : m_string(string) -{ -} - const unsigned char* Utf8View::begin_ptr() const { return (const unsigned char*)m_string.characters_without_null_termination(); diff --git a/AK/Utf8View.h b/AK/Utf8View.h index ed91e39b67..5c63c79708 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -7,6 +7,7 @@ #pragma once +#include <AK/String.h> #include <AK/StringView.h> #include <AK/Types.h> @@ -53,9 +54,17 @@ public: using Iterator = Utf8CodePointIterator; Utf8View() = default; - explicit Utf8View(const String&); - explicit Utf8View(const StringView&); - explicit Utf8View(const char*); + + explicit Utf8View(String& string) + : m_string(string.view()) + { + } + + explicit Utf8View(StringView string) + : m_string(string) + { + } + ~Utf8View() = default; explicit Utf8View(String&&) = delete; |