1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 09:57:34 +00:00

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:
Andreas Kling 2020-02-01 13:54:13 +01:00
parent 625f6c0d86
commit 268000e166

View file

@ -47,13 +47,10 @@ public:
, m_length(length) , m_length(length)
{ {
} }
StringView(const char* cstring) [[gnu::always_inline]] inline StringView(const char* cstring)
: m_characters(cstring) : m_characters(cstring)
, m_length(cstring ? strlen(cstring) : 0)
{ {
if (cstring) {
while (*(cstring++))
++m_length;
}
} }
StringView(const ByteBuffer&); StringView(const ByteBuffer&);