mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 04:13:11 +00:00
LookupServer: Avoid unnecessary copies
This commit is contained in:
parent
182a85c895
commit
95c21977b4
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue