WeakSet.cpp 606 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/WeakSet.h>
  7. namespace JS {
  8. NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
  9. {
  10. return realm.heap().allocate<WeakSet>(realm, realm.intrinsics().weak_set_prototype());
  11. }
  12. WeakSet::WeakSet(Object& prototype)
  13. : Object(ConstructWithPrototypeTag::Tag, prototype)
  14. , WeakContainer(heap())
  15. {
  16. }
  17. void WeakSet::remove_dead_cells(Badge<Heap>)
  18. {
  19. m_values.remove_all_matching([](Cell* cell) {
  20. return cell->state() != Cell::State::Live;
  21. });
  22. }
  23. }