mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 07:37:03 +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
Notes:
sideshowbarker
2024-07-19 02:03:40 +09:00
Author: https://github.com/awesomekling
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