1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:07:45 +00:00

LookupServer: Use HashMap::ensure() in load_etc_hosts()

This commit is contained in:
Andreas Kling 2021-09-04 17:35:41 +02:00
parent 1a71e20f93
commit 363c78e5d2

View file

@ -91,12 +91,7 @@ void LookupServer::load_etc_hosts()
{
m_etc_hosts.clear();
auto add_answer = [this](const DNSName& name, DNSRecordType record_type, String data) {
auto it = m_etc_hosts.find(name);
if (it == m_etc_hosts.end()) {
m_etc_hosts.set(name, {});
it = m_etc_hosts.find(name);
}
it->value.empend(name, record_type, DNSRecordClass::IN, s_static_ttl, data, false);
m_etc_hosts.ensure(name).empend(name, record_type, DNSRecordClass::IN, s_static_ttl, move(data), false);
};
auto file = Core::File::construct("/etc/hosts");