diff --git a/AK/StringView.cpp b/AK/StringView.cpp index 635a4be2d2d..6aa3c6b3364 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -178,6 +178,11 @@ bool StringView::contains(char needle) const return false; } +bool StringView::contains(const StringView& needle) const +{ + return memmem(m_characters, m_length, needle.m_characters, needle.m_length) != nullptr; +} + bool StringView::equals_ignoring_case(const StringView& other) const { return StringUtils::equals_ignoring_case(*this, other); diff --git a/AK/StringView.h b/AK/StringView.h index c0d65a511bb..c61a99e3524 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -83,6 +83,7 @@ public: bool ends_with(char) const; bool matches(const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const; bool contains(char) const; + bool contains(const StringView&) const; bool equals_ignoring_case(const StringView& other) const; Optional find_first_of(char) const;