mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
AK: Make String::count not use strstr and take a StringView
This was needlessly copying StringView arguments, and was also using strstr internally, which meant it was doing a bunch of unnecessary strlen calls on it. This also moves the implementation to StringUtils to allow API consistency between String and StringView.
This commit is contained in:
parent
4e40eaf34c
commit
6d2b003b6e
5 changed files with 19 additions and 17 deletions
|
@ -220,6 +220,8 @@ public:
|
|||
|
||||
[[nodiscard]] bool is_whitespace() const { return StringUtils::is_whitespace(*this); }
|
||||
|
||||
[[nodiscard]] size_t count(StringView const& needle) const { return StringUtils::count(*this, needle); }
|
||||
|
||||
template<typename... Ts>
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts&&... strings) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue