From 718d6e69279386f8f251fefd274813fad622fd8d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 26 Mar 2025 14:08:47 +0000 Subject: [PATCH] LibJS: Make StringOrSymbol::as_string() return a const reference No need to copy the FlyString here, we can avoid the ref count churn. --- Libraries/LibJS/Runtime/StringOrSymbol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibJS/Runtime/StringOrSymbol.h b/Libraries/LibJS/Runtime/StringOrSymbol.h index 4803a323f1e..19e566eb030 100644 --- a/Libraries/LibJS/Runtime/StringOrSymbol.h +++ b/Libraries/LibJS/Runtime/StringOrSymbol.h @@ -57,7 +57,7 @@ public: ALWAYS_INLINE bool is_symbol() const { return is_valid() && (m_bits & 2); } ALWAYS_INLINE bool is_string() const { return is_valid() && !(m_bits & 2); } - ALWAYS_INLINE FlyString as_string() const + ALWAYS_INLINE FlyString const& as_string() const { VERIFY(is_string()); return m_string;