summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Set.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-09 18:34:16 +0330
committerLinus Groh <mail@linusgroh.de>2022-02-09 20:57:41 +0000
commit3bfcd7b52d6fbbe780ac6ee03d5e5505f8009341 (patch)
treed62240860c35054baff3abdde60981e0a4868799 /Userland/Libraries/LibJS/Runtime/Set.cpp
parent4a73ec07c53326c6ae9f8e90f551c1c9bce7d736 (diff)
downloadserenity-3bfcd7b52d6fbbe780ac6ee03d5e5505f8009341.zip
LibJS: Implement Sets using Maps
This implements ordered sets using Maps with a sentinel value, and includes some extra set tests. Fixes #11004. Co-Authored-By: davidot <davidot@serenityos.org>
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Set.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Set.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp
index dfaaf0b28a..32a11c0148 100644
--- a/Userland/Libraries/LibJS/Runtime/Set.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Set.cpp
@@ -15,6 +15,7 @@ Set* Set::create(GlobalObject& global_object)
Set::Set(Object& prototype)
: Object(prototype)
+ , m_values(*prototype.global_object().map_prototype())
{
}
@@ -25,8 +26,7 @@ Set::~Set()
void Set::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
- for (auto& value : m_values)
- visitor.visit(value);
+ static_cast<Object&>(m_values).visit_edges(visitor);
}
}