mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:14:58 +00:00
AK/GenericLexer: constexpr where possible
Problem: - Much of the `GenericLexer` can be `constexpr`, but is not. Solution: - Make it `constexpr` and de-duplicate code. - Extend some of `StringView` with `constexpr` to support. - Add tests to ensure `constexpr` behavior. Note: - Construction of `StringView` from pointer and length is not `constexpr`-compatible at the moment because the VERIFY cannot be, yet.
This commit is contained in:
parent
c2280a907d
commit
254e010c75
6 changed files with 303 additions and 188 deletions
|
@ -172,17 +172,6 @@ bool StringView::equals_ignoring_case(const StringView& other) const
|
|||
return StringUtils::equals_ignoring_case(*this, other);
|
||||
}
|
||||
|
||||
StringView StringView::substring_view(size_t start, size_t length) const
|
||||
{
|
||||
VERIFY(start + length <= m_length);
|
||||
return { m_characters + start, length };
|
||||
}
|
||||
StringView StringView::substring_view(size_t start) const
|
||||
{
|
||||
VERIFY(start <= m_length);
|
||||
return { m_characters + start, length() - start };
|
||||
}
|
||||
|
||||
StringView StringView::substring_view_starting_from_substring(const StringView& substring) const
|
||||
{
|
||||
const char* remaining_characters = substring.characters_without_null_termination();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue