1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 17:37:35 +00:00

LibJS+Everywhere: Return strings by value from PrimitiveString

It turns out return a ThrowCompletionOr<T const&> is flawed, as the GCC
expansion trick used with TRY will always make a copy. PrimitiveString
is luckily the only such use case.
This commit is contained in:
Timothy Flynn 2023-01-13 15:33:31 -05:00 committed by Tim Flynn
parent 9a120d7243
commit a59ebdac2d
10 changed files with 22 additions and 21 deletions

View file

@ -35,7 +35,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyTableConstructor:
auto element_value = TRY(descriptor->get("element"));
if (!element_value.is_string())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidHint, element_value.to_string_without_side_effects());
auto const& element = TRY(element_value.as_string().deprecated_string());
auto element = TRY(element_value.as_string().deprecated_string());
Optional<Wasm::ValueType> reference_type;
if (element == "anyfunc"sv)