mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:57:44 +00:00
LibJS: Add StringOrSymbol constructor that takes a FlyString
This avoids refcount churn from implicit conversion in some places.
This commit is contained in:
parent
3d053f244f
commit
d01b746d88
1 changed files with 8 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/Symbol.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -58,6 +59,13 @@ public:
|
|||
static_cast<const StringImpl*>(m_ptr)->ref();
|
||||
}
|
||||
|
||||
StringOrSymbol(const FlyString& string)
|
||||
: m_ptr(string.impl())
|
||||
{
|
||||
ASSERT(!string.is_null());
|
||||
static_cast<const StringImpl*>(m_ptr)->ref();
|
||||
}
|
||||
|
||||
~StringOrSymbol()
|
||||
{
|
||||
if (is_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue