mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
AK+LibJS+LibRegex: Define an alias for UTF-16 string data storage
Instead of writing out "Vector<u16, 1>" everywhere, let's have a name for it.
This commit is contained in:
parent
39bda0073e
commit
425c168ded
10 changed files with 37 additions and 34 deletions
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Utf16View.h>
|
||||
#include <LibJS/Runtime/Utf16String.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -17,7 +16,7 @@ static NonnullRefPtr<Utf16StringImpl> the_empty_utf16_string()
|
|||
return empty_string;
|
||||
}
|
||||
|
||||
Utf16StringImpl::Utf16StringImpl(Vector<u16, 1> string)
|
||||
Utf16StringImpl::Utf16StringImpl(Utf16Data string)
|
||||
: m_string(move(string))
|
||||
{
|
||||
}
|
||||
|
@ -27,7 +26,7 @@ NonnullRefPtr<Utf16StringImpl> Utf16StringImpl::create()
|
|||
return adopt_ref(*new Utf16StringImpl());
|
||||
}
|
||||
|
||||
NonnullRefPtr<Utf16StringImpl> Utf16StringImpl::create(Vector<u16, 1> string)
|
||||
NonnullRefPtr<Utf16StringImpl> Utf16StringImpl::create(Utf16Data string)
|
||||
{
|
||||
return adopt_ref(*new Utf16StringImpl(move(string)));
|
||||
}
|
||||
|
@ -39,13 +38,13 @@ NonnullRefPtr<Utf16StringImpl> Utf16StringImpl::create(StringView string)
|
|||
|
||||
NonnullRefPtr<Utf16StringImpl> Utf16StringImpl::create(Utf16View const& view)
|
||||
{
|
||||
Vector<u16, 1> string;
|
||||
Utf16Data string;
|
||||
string.ensure_capacity(view.length_in_code_units());
|
||||
string.append(view.data(), view.length_in_code_units());
|
||||
return create(move(string));
|
||||
}
|
||||
|
||||
Vector<u16, 1> const& Utf16StringImpl::string() const
|
||||
Utf16Data const& Utf16StringImpl::string() const
|
||||
{
|
||||
return m_string;
|
||||
}
|
||||
|
@ -62,7 +61,7 @@ Utf16String::Utf16String()
|
|||
{
|
||||
}
|
||||
|
||||
Utf16String::Utf16String(Vector<u16, 1> string)
|
||||
Utf16String::Utf16String(Utf16Data string)
|
||||
: m_string(Detail::Utf16StringImpl::create(move(string)))
|
||||
{
|
||||
}
|
||||
|
@ -77,7 +76,7 @@ Utf16String::Utf16String(Utf16View const& string)
|
|||
{
|
||||
}
|
||||
|
||||
Vector<u16, 1> const& Utf16String::string() const
|
||||
Utf16Data const& Utf16String::string() const
|
||||
{
|
||||
return m_string->string();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue