summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-19 15:19:34 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-21 20:17:36 +0200
commitd831b5738d932e723415fd0a37f01ea47b1c2dec (patch)
tree02acdb3e442084f7838de0ecb25dfcb0081eae05
parentb7bd2ed9d2e3343d806c2cd92ff52f2ed0087cf1 (diff)
downloadserenity-d831b5738d932e723415fd0a37f01ea47b1c2dec.zip
AK: Add StringView::substring_view(size_t) overload.
-rw-r--r--AK/StringView.cpp5
-rw-r--r--AK/StringView.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/AK/StringView.cpp b/AK/StringView.cpp
index 6aa3c6b336..57f476d0da 100644
--- a/AK/StringView.cpp
+++ b/AK/StringView.cpp
@@ -193,6 +193,11 @@ StringView StringView::substring_view(size_t start, size_t length) const
ASSERT(start + length <= m_length);
return { m_characters + start, length };
}
+StringView StringView::substring_view(size_t start) const
+{
+ ASSERT(start <= m_length);
+ return { m_characters + start, length() - start };
+}
StringView StringView::substring_view_starting_from_substring(const StringView& substring) const
{
diff --git a/AK/StringView.h b/AK/StringView.h
index 9a03fd9bc8..2f99cd48a4 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -98,6 +98,7 @@ public:
Optional<size_t> find_last_of(const StringView&) const;
StringView substring_view(size_t start, size_t length) const;
+ StringView substring_view(size_t start) const;
Vector<StringView> split_view(char, bool keep_empty = false) const;
Vector<StringView> split_view(const StringView&, bool keep_empty = false) const;