1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

AK: Add implicit String -> StringView conversion

And tidy up existing view() users.
This commit is contained in:
Robin Burchell 2019-06-02 12:19:21 +02:00 committed by Andreas Kling
parent decf1afbaa
commit b55b6cd7fc
6 changed files with 13 additions and 6 deletions

View file

@ -3,6 +3,12 @@
namespace AK {
StringView::StringView(const AK::String& string)
: m_characters(string.characters())
, m_length(string.length())
{
}
Vector<StringView> StringView::split_view(const char separator) const
{
if (is_empty())
@ -23,7 +29,7 @@ Vector<StringView> StringView::split_view(const char separator) const
if (taillen != 0)
v.append(substring_view(substart, taillen));
if (characters()[length() - 1] == separator)
v.append(String::empty().view());
v.append(String::empty());
return v;
}