diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-02-09 18:34:16 +0330 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-09 20:57:41 +0000 |
commit | 3bfcd7b52d6fbbe780ac6ee03d5e5505f8009341 (patch) | |
tree | d62240860c35054baff3abdde60981e0a4868799 /Userland/Utilities/js.cpp | |
parent | 4a73ec07c53326c6ae9f8e90f551c1c9bce7d736 (diff) | |
download | serenity-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/Utilities/js.cpp')
-rw-r--r-- | Userland/Utilities/js.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 066bc1d0ef..51c1994690 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -375,13 +375,12 @@ static void print_map(JS::Object const& object, HashTable<JS::Object*>& seen_obj static void print_set(JS::Object const& object, HashTable<JS::Object*>& seen_objects) { auto& set = static_cast<JS::Set const&>(object); - auto& values = set.values(); print_type("Set"); js_out(" {{"); bool first = true; - for (auto& value : values) { + for (auto& entry : set) { print_separator(first); - print_value(value, seen_objects); + print_value(entry.key, seen_objects); } if (!first) js_out(" "); |