From 1c8adac4423aca47d765eb2f4a1fed934f3e7bd0 Mon Sep 17 00:00:00 2001 From: Hediadyoin1 Date: Tue, 21 Feb 2023 11:32:30 +0100 Subject: [PATCH] LibJS: Use HashTable::take_first in GetObjectPropertyIterator This is a bit more idiomatic than ```c++ auto it = table.begin(); auto k = *it; table.remove(it); ``` and also saves us from copying the stored value. --- Userland/Libraries/LibJS/Bytecode/Op.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 9349e97dd3..c276c8dfb2 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -939,9 +939,7 @@ ThrowCompletionOr GetObjectPropertyIterator::execute_impl(Bytecode::Interp return result_object; } - auto it = items.begin(); - auto key = *it; - items.remove(it); + auto key = items.take_first(); // If the key was already seen, skip over it (invariant no. 4) auto result = seen_items.set(key);