diff --git a/AK/String.cpp b/AK/String.cpp index 6d5ca976274..3e188c49e88 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -147,6 +147,13 @@ StringView String::substring_view(size_t start, size_t length) const return { characters() + start, length }; } +StringView String::substring_view(size_t start) const +{ + ASSERT(m_impl); + ASSERT(start <= length()); + return { characters() + start, length() - start }; +} + Vector String::split(char separator, bool keep_empty) const { return split_limit(separator, 0, keep_empty); diff --git a/AK/String.h b/AK/String.h index 51e3c51de02..f8549113130 100644 --- a/AK/String.h +++ b/AK/String.h @@ -138,6 +138,7 @@ public: Vector split_view(char separator, bool keep_empty = false) const; StringView substring_view(size_t start, size_t length) const; + StringView substring_view(size_t start) const; bool is_null() const { return !m_impl; } ALWAYS_INLINE bool is_empty() const { return length() == 0; }