diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index d49ba18692..fcac008c01 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -21,9 +21,10 @@ static constexpr u32 replacement_code_point = 0xfffd; static constexpr u32 first_supplementary_plane_code_point = 0x10000; template -static Vector to_utf16_impl(UtfViewType const& view) requires(IsSame || IsSame) +static Vector to_utf16_impl(UtfViewType const& view) requires(IsSame || IsSame) { - Vector utf16_data; + Vector utf16_data; + utf16_data.ensure_capacity(view.length()); for (auto code_point : view) code_point_to_utf16(utf16_data, code_point); @@ -31,22 +32,22 @@ static Vector to_utf16_impl(UtfViewType const& view) requires(IsSame utf8_to_utf16(StringView const& utf8_view) +Vector utf8_to_utf16(StringView const& utf8_view) { return to_utf16_impl(Utf8View { utf8_view }); } -Vector utf8_to_utf16(Utf8View const& utf8_view) +Vector utf8_to_utf16(Utf8View const& utf8_view) { return to_utf16_impl(utf8_view); } -Vector utf32_to_utf16(Utf32View const& utf32_view) +Vector utf32_to_utf16(Utf32View const& utf32_view) { return to_utf16_impl(utf32_view); } -void code_point_to_utf16(Vector& string, u32 code_point) +void code_point_to_utf16(Vector& string, u32 code_point) { VERIFY(is_unicode(code_point)); diff --git a/AK/Utf16View.h b/AK/Utf16View.h index a332ed6a23..805ab08000 100644 --- a/AK/Utf16View.h +++ b/AK/Utf16View.h @@ -16,10 +16,10 @@ namespace AK { -Vector utf8_to_utf16(StringView const&); -Vector utf8_to_utf16(Utf8View const&); -Vector utf32_to_utf16(Utf32View const&); -void code_point_to_utf16(Vector&, u32); +Vector utf8_to_utf16(StringView const&); +Vector utf8_to_utf16(Utf8View const&); +Vector utf32_to_utf16(Utf32View const&); +void code_point_to_utf16(Vector&, u32); class Utf16View; diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index cbac0b8d0d..d13a4f089f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -140,7 +140,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_char_code) // 22.1.2.2 String.fromCodePoint ( ...codePoints ), https://tc39.es/ecma262/#sec-string.fromcodepoint JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point) { - Vector string; + Vector string; string.ensure_capacity(vm.argument_count()); // This will be an under-estimate if any code point is > 0xffff. for (size_t i = 0; i < vm.argument_count(); ++i) { diff --git a/Userland/Libraries/LibJS/Runtime/Utf16String.cpp b/Userland/Libraries/LibJS/Runtime/Utf16String.cpp index b2e40c252f..e5ad11e822 100644 --- a/Userland/Libraries/LibJS/Runtime/Utf16String.cpp +++ b/Userland/Libraries/LibJS/Runtime/Utf16String.cpp @@ -17,7 +17,7 @@ static NonnullRefPtr the_empty_utf16_string() return empty_string; } -Utf16StringImpl::Utf16StringImpl(Vector string) +Utf16StringImpl::Utf16StringImpl(Vector string) : m_string(move(string)) { } @@ -27,7 +27,7 @@ NonnullRefPtr Utf16StringImpl::create() return adopt_ref(*new Utf16StringImpl()); } -NonnullRefPtr Utf16StringImpl::create(Vector string) +NonnullRefPtr Utf16StringImpl::create(Vector string) { return adopt_ref(*new Utf16StringImpl(move(string))); } @@ -39,13 +39,13 @@ NonnullRefPtr Utf16StringImpl::create(StringView const& string) NonnullRefPtr Utf16StringImpl::create(Utf16View const& view) { - Vector string; + Vector string; string.ensure_capacity(view.length_in_code_units()); string.append(view.data(), view.length_in_code_units()); return create(move(string)); } -Vector const& Utf16StringImpl::string() const +Vector const& Utf16StringImpl::string() const { return m_string; } @@ -62,7 +62,7 @@ Utf16String::Utf16String() { } -Utf16String::Utf16String(Vector string) +Utf16String::Utf16String(Vector string) : m_string(Detail::Utf16StringImpl::create(move(string))) { } @@ -77,7 +77,7 @@ Utf16String::Utf16String(Utf16View const& string) { } -Vector const& Utf16String::string() const +Vector const& Utf16String::string() const { return m_string->string(); } diff --git a/Userland/Libraries/LibJS/Runtime/Utf16String.h b/Userland/Libraries/LibJS/Runtime/Utf16String.h index 640de51218..e38e5b4592 100644 --- a/Userland/Libraries/LibJS/Runtime/Utf16String.h +++ b/Userland/Libraries/LibJS/Runtime/Utf16String.h @@ -20,18 +20,18 @@ public: ~Utf16StringImpl() = default; static NonnullRefPtr create(); - static NonnullRefPtr create(Vector); + static NonnullRefPtr create(Vector); static NonnullRefPtr create(StringView const&); static NonnullRefPtr create(Utf16View const&); - Vector const& string() const; + Vector const& string() const; Utf16View view() const; private: Utf16StringImpl() = default; - explicit Utf16StringImpl(Vector string); + explicit Utf16StringImpl(Vector string); - Vector m_string; + Vector m_string; }; } @@ -39,11 +39,11 @@ private: class Utf16String { public: Utf16String(); - explicit Utf16String(Vector); + explicit Utf16String(Vector); explicit Utf16String(StringView const&); explicit Utf16String(Utf16View const&); - Vector const& string() const; + Vector const& string() const; Utf16View view() const; Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const; Utf16View substring_view(size_t code_unit_offset) const; diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp index 231c076d10..2b6bc146c7 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.cpp +++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp @@ -470,7 +470,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M return ExecutionResult::Failed_ExecuteLowPrioForks; Optional str; - Vector utf16; + Vector utf16; Vector data; data.ensure_capacity(length); for (size_t i = offset; i < offset + length; ++i) @@ -557,7 +557,7 @@ ALWAYS_INLINE void OpCode_Compare::compare_char(MatchInput const& input, MatchSt auto input_view = input.view.substring_view(state.string_position, 1); Optional str; - Vector utf16; + Vector utf16; auto compare_view = input_view.construct_as_same({ &ch1, 1 }, str, utf16); bool equal; if (input.regex_options & AllFlags::Insensitive) diff --git a/Userland/Libraries/LibRegex/RegexMatch.h b/Userland/Libraries/LibRegex/RegexMatch.h index 60a1241eb3..6d707650ee 100644 --- a/Userland/Libraries/LibRegex/RegexMatch.h +++ b/Userland/Libraries/LibRegex/RegexMatch.h @@ -139,7 +139,7 @@ public: return view; } - RegexStringView construct_as_same(Span data, Optional& optional_string_storage, Vector& optional_utf16_storage) const + RegexStringView construct_as_same(Span data, Optional& optional_string_storage, Vector& optional_utf16_storage) const { auto view = m_view.visit( [&](T const&) {