From 95c21977b4cad7d87c03f534a224916a78bfeba1 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 5 Dec 2021 12:10:17 +0100 Subject: LookupServer: Avoid unnecessary copies --- Userland/Services/LookupServer/LookupServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp index 2018901088..16c12b5f15 100644 --- a/Userland/Services/LookupServer/LookupServer.cpp +++ b/Userland/Services/LookupServer/LookupServer.cpp @@ -149,8 +149,8 @@ Vector LookupServer::lookup(const DNSName& name, DNSRecordType record }; // First, try /etc/hosts. - if (auto local_answers = m_etc_hosts.get(name); local_answers.has_value()) { - for (auto& answer : local_answers.value()) { + if (auto local_answers = m_etc_hosts.find(name); local_answers != m_etc_hosts.end()) { + for (auto& answer : local_answers->value) { if (answer.type() == record_type) add_answer(answer); } @@ -169,8 +169,8 @@ Vector LookupServer::lookup(const DNSName& name, DNSRecordType record } // Third, try our cache. - if (auto cached_answers = m_lookup_cache.get(name); cached_answers.has_value()) { - for (auto& answer : cached_answers.value()) { + if (auto cached_answers = m_lookup_cache.find(name); cached_answers != m_lookup_cache.end()) { + for (auto& answer : cached_answers->value) { // TODO: Actually remove expired answers from the cache. if (answer.type() == record_type && !answer.has_expired()) { dbgln_if(LOOKUPSERVER_DEBUG, "Cache hit: {} -> {}", name.as_string(), answer.record_data()); -- cgit v1.2.3