1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:27:45 +00:00

LibJS: Tweak the WeakContainer::remove_swept_cells() API a little bit

Make this API take a Span<Cell*> instead of a Vector<Cell*>&.
This is behavior neutral, but stops the API looking like it wants to
do mutable things to the Vector.
This commit is contained in:
Andreas Kling 2021-09-11 12:02:38 +02:00
parent 9b5696fee7
commit 470c99a2a6
10 changed files with 11 additions and 11 deletions

View file

@ -251,7 +251,7 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
}
for (auto& weak_container : m_weak_containers)
weak_container.remove_swept_cells({}, swept_cells);
weak_container.remove_swept_cells({}, swept_cells.span());
if constexpr (HEAP_DEBUG) {
for_each_block([&](auto& block) {

View file

@ -42,10 +42,10 @@ bool FinalizationRegistry::remove_by_token(Object& unregister_token)
return removed;
}
void FinalizationRegistry::remove_swept_cells(Badge<Heap>, Vector<Cell*>& cells)
void FinalizationRegistry::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
{
auto any_cells_were_swept = false;
for (auto cell : cells) {
for (auto* cell : cells) {
for (auto& record : m_records) {
if (record.target != cell)
continue;

View file

@ -30,7 +30,7 @@ public:
bool remove_by_token(Object& unregister_token);
void cleanup(FunctionObject* callback = nullptr);
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) override;
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
private:
virtual void visit_edges(Visitor& visitor) override;

View file

@ -15,7 +15,7 @@ public:
explicit WeakContainer(Heap&);
virtual ~WeakContainer();
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) = 0;
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) = 0;
protected:
void deregister();

View file

@ -23,7 +23,7 @@ WeakMap::~WeakMap()
{
}
void WeakMap::remove_swept_cells(Badge<Heap>, Vector<Cell*>& cells)
void WeakMap::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
{
for (auto* cell : cells)
m_values.remove(cell);

View file

@ -27,7 +27,7 @@ public:
HashMap<Cell*, Value> const& values() const { return m_values; };
HashMap<Cell*, Value>& values() { return m_values; };
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) override;
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
private:
HashMap<Cell*, Value> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping

View file

@ -25,7 +25,7 @@ WeakRef::~WeakRef()
{
}
void WeakRef::remove_swept_cells(Badge<Heap>, Vector<Cell*>& cells)
void WeakRef::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
{
VERIFY(m_value);
for (auto* cell : cells) {

View file

@ -27,7 +27,7 @@ public:
void update_execution_generation() { m_last_execution_generation = vm().execution_generation(); };
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) override;
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
private:
virtual void visit_edges(Visitor&) override;

View file

@ -23,7 +23,7 @@ WeakSet::~WeakSet()
{
}
void WeakSet::remove_swept_cells(Badge<Heap>, Vector<Cell*>& cells)
void WeakSet::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
{
for (auto* cell : cells)
m_values.remove(cell);

View file

@ -27,7 +27,7 @@ public:
HashTable<Cell*> const& values() const { return m_values; };
HashTable<Cell*>& values() { return m_values; };
virtual void remove_swept_cells(Badge<Heap>, Vector<Cell*>&) override;
virtual void remove_swept_cells(Badge<Heap>, Span<Cell*>) override;
private:
HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping