summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-04-03 18:04:57 +0430
committerAndreas Kling <kling@serenityos.org>2022-04-04 12:48:31 +0200
commit33e27c545ed7515185ef93ed0c0c0f49e6759e01 (patch)
treea166a005853cd101ef96ded3d5e43cde2e972e2d /Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
parent1a74895680bd7dc6af50c73f2191c10b46b54a75 (diff)
downloadserenity-33e27c545ed7515185ef93ed0c0c0f49e6759e01.zip
AK: Return Optional<T&> from HashMap<..., T>::get()
This avoids a useless copy of the value, as most of the users (except one) actually just need a reference to the value.
Diffstat (limited to 'Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp')
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
index d90c092eec..95c586ce6b 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
@@ -34,7 +34,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
for (auto& export_ : instance.exports()) {
export_.value().visit(
[&](Wasm::FunctionAddress const& address) {
- auto object = cache.function_instances.get(address);
+ Optional<JS::FunctionObject*> object = cache.function_instances.get(address);
if (!object.has_value()) {
object = create_native_function(global_object, address, export_.name());
cache.function_instances.set(address, *object);
@@ -42,7 +42,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes);
},
[&](Wasm::MemoryAddress const& address) {
- auto object = cache.memory_instances.get(address);
+ Optional<WebAssemblyMemoryObject*> object = cache.memory_instances.get(address);
if (!object.has_value()) {
object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, global_object, address);
cache.memory_instances.set(address, *object);