mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibJS: Allow advancing built-in iterators without result object creation
Expose a method on built-in iterators that allows retrieving the next iteration result without allocating a JS::Object. This change is a preparation for optimizing for..of and for..in loops.
This commit is contained in:
parent
c72d5943e6
commit
ab52d86a69
Notes:
github-actions[bot]
2025-04-30 18:52:44 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: ab52d86a69
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4533
15 changed files with 234 additions and 169 deletions
|
@ -6,13 +6,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashTable.h>
|
||||
#include <LibJS/Runtime/Iterator.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Set.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class SetIterator final : public Object {
|
||||
class SetIterator final : public Object
|
||||
, public BuiltinIterator {
|
||||
JS_OBJECT(SetIterator, Object);
|
||||
GC_DECLARE_ALLOCATOR(SetIterator);
|
||||
|
||||
|
@ -21,9 +22,8 @@ public:
|
|||
|
||||
virtual ~SetIterator() override = default;
|
||||
|
||||
Set& set() const { return m_set; }
|
||||
bool done() const { return m_done; }
|
||||
Object::PropertyKind iteration_kind() const { return m_iteration_kind; }
|
||||
BuiltinIterator* as_builtin_iterator() override { return this; }
|
||||
ThrowCompletionOr<void> next(VM&, bool& done, Value& value) override;
|
||||
|
||||
private:
|
||||
friend class SetIteratorPrototype;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue