mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
Assistant: Use HashMap::ensure() in Database::did_receive_results()
This commit is contained in:
parent
6f6473d6a4
commit
769f777098
1 changed files with 3 additions and 7 deletions
|
@ -146,19 +146,15 @@ private:
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Threading::MutexLocker db_locker(m_mutex);
|
Threading::MutexLocker db_locker(m_mutex);
|
||||||
auto it = m_result_cache.find(query);
|
auto& cache_entry = m_result_cache.ensure(query);
|
||||||
if (it == m_result_cache.end()) {
|
|
||||||
m_result_cache.set(query, {});
|
|
||||||
}
|
|
||||||
it = m_result_cache.find(query);
|
|
||||||
|
|
||||||
for (auto& result : results) {
|
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);
|
return result.equals(other);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (found.is_end())
|
if (found.is_end())
|
||||||
it->value.append(result);
|
cache_entry.append(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue