LibJS: Use Vector<u16, 1> for UTF-16 in a few more places

This commit is contained in:
Andreas Kling 2021-10-02 17:41:34 +02:00
parent dc99b702be
commit f0b3a06746
Notes: sideshowbarker 2024-07-18 03:12:21 +09:00
3 changed files with 3 additions and 3 deletions

View file

@ -124,7 +124,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
// 22.1.2.1 String.fromCharCode ( ...codeUnits ), https://tc39.es/ecma262/#sec-string.fromcharcode
JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_char_code)
{
Vector<u16> string;
Vector<u16, 1> string;
string.ensure_capacity(vm.argument_count());
for (size_t i = 0; i < vm.argument_count(); ++i) {

View file

@ -483,7 +483,7 @@ static Value pad_string(GlobalObject& global_object, Utf16String string, PadPlac
if (max_length <= string_length)
return js_string(vm, move(string));
Utf16String fill_string(Vector<u16> { 0x20 });
Utf16String fill_string(Vector<u16, 1> { 0x20 });
if (!vm.argument(1).is_undefined()) {
fill_string = vm.argument(1).to_utf16_string(global_object);
if (vm.exception())

View file

@ -1106,7 +1106,7 @@ Value add(GlobalObject& global_object, Value lhs, Value rhs)
auto const& lhs_utf16_string = lhs_string.utf16_string();
auto const& rhs_utf16_string = rhs_string.utf16_string();
Vector<u16> combined;
Vector<u16, 1> combined;
combined.ensure_capacity(lhs_utf16_string.length_in_code_units() + rhs_utf16_string.length_in_code_units());
combined.extend(lhs_utf16_string.string());
combined.extend(rhs_utf16_string.string());