mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add String::substring_view(size_t).
This commit is contained in:
parent
ac2358ff0d
commit
78eff163ea
Notes:
sideshowbarker
2024-07-19 00:57:32 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/78eff163eab Pull-request: https://github.com/SerenityOS/serenity/pull/4318 Reviewed-by: https://github.com/Lubrsi Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
2 changed files with 8 additions and 0 deletions
|
@ -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> String::split(char separator, bool keep_empty) const
|
||||
{
|
||||
return split_limit(separator, 0, keep_empty);
|
||||
|
|
|
@ -138,6 +138,7 @@ public:
|
|||
|
||||
Vector<StringView> 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; }
|
||||
|
|
Loading…
Reference in a new issue