AK: Always inline StringView(const char*)
Also use strlen() instead of manually walking the string. This allows GCC to optimize away the strlen() entirely for string literals. :^)
This commit is contained in:
parent
625f6c0d86
commit
268000e166
Notes:
sideshowbarker
2024-07-19 09:43:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/268000e1664
1 changed files with 2 additions and 5 deletions
|
@ -47,13 +47,10 @@ public:
|
|||
, m_length(length)
|
||||
{
|
||||
}
|
||||
StringView(const char* cstring)
|
||||
[[gnu::always_inline]] inline StringView(const char* cstring)
|
||||
: m_characters(cstring)
|
||||
, m_length(cstring ? strlen(cstring) : 0)
|
||||
{
|
||||
if (cstring) {
|
||||
while (*(cstring++))
|
||||
++m_length;
|
||||
}
|
||||
}
|
||||
|
||||
StringView(const ByteBuffer&);
|
||||
|
|
Loading…
Add table
Reference in a new issue