summaryrefslogtreecommitdiff
path: root/Userland/Applications/Assistant
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-04 17:49:28 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-04 20:30:56 +0200
commit769f777098587f18b8957d1572fcfc1cba18f110 (patch)
tree9d41c00807a95ca094a8f9e16780f075a46bf2da /Userland/Applications/Assistant
parent6f6473d6a40a5deb5e95499545c90a865fbc711f (diff)
downloadserenity-769f777098587f18b8957d1572fcfc1cba18f110.zip
Assistant: Use HashMap::ensure() in Database::did_receive_results()
Diffstat (limited to 'Userland/Applications/Assistant')
-rw-r--r--Userland/Applications/Assistant/main.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp
index 0f6a7c01fa..90dd67dd29 100644
--- a/Userland/Applications/Assistant/main.cpp
+++ b/Userland/Applications/Assistant/main.cpp
@@ -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);
}
}