1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:38:13 +00:00

Assistant: Use HashMap::ensure() in Database::did_receive_results()

This commit is contained in:
Andreas Kling 2021-09-04 17:49:28 +02:00
parent 6f6473d6a4
commit 769f777098

View file

@ -146,19 +146,15 @@ private:
{
{
Threading::MutexLocker db_locker(m_mutex);
auto it = m_result_cache.find(query);
if (it == m_result_cache.end()) {
m_result_cache.set(query, {});
}
it = m_result_cache.find(query);
auto& cache_entry = m_result_cache.ensure(query);
for (auto& result : results) {
auto found = it->value.find_if([&result](auto& other) {
auto found = cache_entry.find_if([&result](auto& other) {
return result.equals(other);
});
if (found.is_end())
it->value.append(result);
cache_entry.append(result);
}
}