Commit 094d9ade authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Minor refactor when adding to std::unordered_map

This patch uses the return value of |insert| to check if the
key is already in the map or not.

This patch has no behavior changes.

Bug: 652964
Change-Id: I6d53b923a7dbb8b39fdb03ec1a833ff8e88b5c9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462856
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816149}
parent 35e29c7e
......@@ -33,11 +33,11 @@ base::File GetDictionaryFile(const std::string& locale) {
// Keep Files open in the cache for subsequent calls.
static base::NoDestructor<DictionaryFileMap> cache;
const auto& it = cache->find(locale);
if (it != cache->end())
return it->second.Duplicate();
const auto& inserted = cache->insert(std::make_pair(locale, base::File()));
base::File& file = inserted.first->second;
// If the |locale| is already in the cache, duplicate the file and return it.
if (!inserted.second)
return file.Duplicate();
DCHECK(!file.IsValid());
#if defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment