diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 7099bb8124..f540032326 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -52,7 +52,7 @@ void GeneratorObject::visit_edges(Cell::Visitor& visitor) } // 27.5.3.2 GeneratorValidate ( generator, generatorBrand ), https://tc39.es/ecma262/#sec-generatorvalidate -ThrowCompletionOr GeneratorObject::validate(VM& vm, Optional const& generator_brand) +ThrowCompletionOr GeneratorObject::validate(VM& vm, Optional const& generator_brand) { // 1. Perform ? RequireInternalSlot(generator, [[GeneratorState]]). // 2. Perform ? RequireInternalSlot(generator, [[GeneratorBrand]]). @@ -60,7 +60,7 @@ ThrowCompletionOr GeneratorObject::validate(VM& // 3. If generator.[[GeneratorBrand]] is not the same value as generatorBrand, throw a TypeError exception. if (m_generator_brand != generator_brand) - return vm.throw_completion(ErrorType::GeneratorBrandMismatch, m_generator_brand.value_or(""), generator_brand.value_or("")); + return vm.throw_completion(ErrorType::GeneratorBrandMismatch, m_generator_brand.value_or(""sv), generator_brand.value_or(""sv)); // 4. Assert: generator also has a [[GeneratorContext]] internal slot. // NOTE: Done by already being a GeneratorObject. @@ -140,7 +140,7 @@ ThrowCompletionOr GeneratorObject::execute(VM& vm, Completion const& comp } // 27.5.3.3 GeneratorResume ( generator, value, generatorBrand ), https://tc39.es/ecma262/#sec-generatorresume -ThrowCompletionOr GeneratorObject::resume(VM& vm, Value value, Optional generator_brand) +ThrowCompletionOr GeneratorObject::resume(VM& vm, Value value, Optional const& generator_brand) { // 1. Let state be ? GeneratorValidate(generator, generatorBrand). auto state = TRY(validate(vm, generator_brand)); @@ -179,7 +179,7 @@ ThrowCompletionOr GeneratorObject::resume(VM& vm, Value value, Optional GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional generator_brand) +ThrowCompletionOr GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional const& generator_brand) { // Not part of the spec, but the spec assumes abruptCompletion.[[Value]] is not empty. VERIFY(abrupt_completion.value().has_value()); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index c4f3ed4155..2989d41dd6 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -20,8 +20,8 @@ public: virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; - ThrowCompletionOr resume(VM&, Value value, Optional generator_brand); - ThrowCompletionOr resume_abrupt(VM&, JS::Completion abrupt_completion, Optional generator_brand); + ThrowCompletionOr resume(VM&, Value value, Optional const& generator_brand); + ThrowCompletionOr resume_abrupt(VM&, JS::Completion abrupt_completion, Optional const& generator_brand); private: GeneratorObject(Realm&, Object& prototype, ExecutionContext); @@ -33,7 +33,7 @@ private: Completed, }; - ThrowCompletionOr validate(VM&, Optional const& generator_brand); + ThrowCompletionOr validate(VM&, Optional const& generator_brand); ThrowCompletionOr execute(VM&, JS::Completion const& completion); ExecutionContext m_execution_context; @@ -41,7 +41,7 @@ private: Value m_previous_value; Optional m_frame; GeneratorState m_generator_state { GeneratorState::SuspendedStart }; - Optional m_generator_brand; + Optional m_generator_brand; }; }