summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-11 12:02:38 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-11 12:09:55 +0200
commit470c99a2a6ac793d60a044621681420aef91623b (patch)
tree2c45c48aac6e9da6a2488ed945ee7069c9793a65 /Userland/Libraries
parent9b5696fee7012fc4ff75eed57ee6f77009dcb18c (diff)
downloadserenity-470c99a2a6ac793d60a044621681420aef91623b.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Heap/Heap.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakContainer.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMap.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMap.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRef.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRef.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSet.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSet.h2
10 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp
index d0bc3ba289..4c5b9292d0 100644
--- a/Userland/Libraries/LibJS/Heap/Heap.cpp
+++ b/Userland/Libraries/LibJS/Heap/Heap.cpp
@@ -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) {
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp
index 9e012043d6..01713fa39f 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp
@@ -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;
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h
index 8753f0838c..27ef6e1695 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h
@@ -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;
diff --git a/Userland/Libraries/LibJS/Runtime/WeakContainer.h b/Userland/Libraries/LibJS/Runtime/WeakContainer.h
index 8e469fb9ed..3a5cc8825b 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakContainer.h
+++ b/Userland/Libraries/LibJS/Runtime/WeakContainer.h
@@ -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();
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
index d689bb5a97..8bd9a7a9c7 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
@@ -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);
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.h b/Userland/Libraries/LibJS/Runtime/WeakMap.h
index e530cb95c1..18a6b74305 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMap.h
+++ b/Userland/Libraries/LibJS/Runtime/WeakMap.h
@@ -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
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
index 868cea8457..85ac7b6621 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
@@ -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) {
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.h b/Userland/Libraries/LibJS/Runtime/WeakRef.h
index 91c2ddb551..d93202ed55 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRef.h
+++ b/Userland/Libraries/LibJS/Runtime/WeakRef.h
@@ -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;
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
index ebf717ffc6..6d269ea38c 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
@@ -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);
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.h b/Userland/Libraries/LibJS/Runtime/WeakSet.h
index 80bcba5708..36433f86c5 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSet.h
+++ b/Userland/Libraries/LibJS/Runtime/WeakSet.h
@@ -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