mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibJS: Add PrimitiveString::is_empty() and use it
If we're only interested in whether the string is empty, we can skip the conversion from UTF-16 to UTF-8.
This commit is contained in:
parent
32480fbeb9
commit
f4c68eb0a4
3 changed files with 12 additions and 1 deletions
|
@ -32,6 +32,15 @@ PrimitiveString::~PrimitiveString()
|
|||
vm().string_cache().remove(m_utf8_string);
|
||||
}
|
||||
|
||||
bool PrimitiveString::is_empty() const
|
||||
{
|
||||
if (m_has_utf16_string)
|
||||
return m_utf16_string.is_empty();
|
||||
if (m_has_utf8_string)
|
||||
return m_utf8_string.is_empty();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String const& PrimitiveString::string() const
|
||||
{
|
||||
if (!m_has_utf8_string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue