summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-12-05 12:10:17 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-01 15:40:39 +0100
commit95c21977b4cad7d87c03f534a224916a78bfeba1 (patch)
tree2e80bd92fec4b7d8e816d6c0f15431da0b9bef1b
parent182a85c895d650c2e0b20321977726c058521129 (diff)
downloadserenity-95c21977b4cad7d87c03f534a224916a78bfeba1.zip
LookupServer: Avoid unnecessary copies
-rw-r--r--Userland/Services/LookupServer/LookupServer.cpp8
1 files 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<DNSAnswer> 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<DNSAnswer> 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());