summaryrefslogtreecommitdiff
path: root/AK/StringView.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-06 20:39:11 +0000
committerLinus Groh <mail@linusgroh.de>2022-12-07 09:58:38 +0000
commitf23b55ae8681c818add83e025fca5a3e7282bda8 (patch)
tree035da09e31a5fbb531a97d04c2dcf8cad9641841 /AK/StringView.cpp
parentdaec065fdea58840444e61ccfdb71bf6514fa6d5 (diff)
downloadserenity-f23b55ae8681c818add83e025fca5a3e7282bda8.zip
AK: Add StringView(String const&) constructor
This allows us to pass the new String type to functions that take a StringView directly, having to call bytes_as_string_view() every time gets old quickly.
Diffstat (limited to 'AK/StringView.cpp')
-rw-r--r--AK/StringView.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/AK/StringView.cpp b/AK/StringView.cpp
index f6b6c3648d..f299ab707b 100644
--- a/AK/StringView.cpp
+++ b/AK/StringView.cpp
@@ -16,11 +16,18 @@
#ifndef KERNEL
# include <AK/DeprecatedString.h>
# include <AK/FlyString.h>
+# include <AK/String.h>
#endif
namespace AK {
#ifndef KERNEL
+StringView::StringView(String const& string)
+ : m_characters(reinterpret_cast<char const*>(string.bytes().data()))
+ , m_length(string.bytes().size())
+{
+}
+
StringView::StringView(DeprecatedString const& string)
: m_characters(string.characters())
, m_length(string.length())