Truly independent web browser
LibWeb: Move completed module fetch callbacks into a RootVector
Shannon Boothe257973f0117
diff --git a/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp b/Libraries/LibWeb/HTML/Scripting/ModuleMap.cppindex ca615ced4a4..15c1116e19a 100644--- a/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp+++ b/Libraries/LibWeb/HTML/Scripting/ModuleMap.cpp@@ -39,15 +39,10 @@ void ModuleMap::append(URL::URL const& url, Utf16View type, CallbackFunction calvoid ModuleMap::complete_fetch(URL::URL const& url, Utf16View type, GC::Ptr<ModuleScript> module_script){- auto entry = m_values.take({ url, type });- VERIFY(entry.has_value());- auto value = entry.release_value();- auto callbacks_to_invoke = move(value.get<CallbackList>());-- Vector<GC::Root<GC::Function<void(GC::Ptr<ModuleScript>)>>> callbacks;- callbacks.ensure_capacity(callbacks_to_invoke.size());- for (auto const& callback : callbacks_to_invoke)- callbacks.unchecked_append(GC::make_root(callback));+ auto entry = m_values.find({ url, type });+ VERIFY(entry != m_values.end());+ GC::RootVector callbacks { move(entry->value.get<CallbackList>()) };+ m_values.remove(entry);if (module_script)m_values.set({ url, type }, GC::Ref { *module_script });