Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: chrome/browser/android/thumbnail/thumbnail_cache.cc

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per latest code Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/thumbnail/thumbnail_cache.cc
diff --git a/chrome/browser/android/thumbnail/thumbnail_cache.cc b/chrome/browser/android/thumbnail/thumbnail_cache.cc
index 3f8e90553e3ee572786f3c160a59b47990d970c1..0fecbf03bf0774d87aecfec0e528b3e4f80c9a29 100644
--- a/chrome/browser/android/thumbnail/thumbnail_cache.cc
+++ b/chrome/browser/android/thumbnail/thumbnail_cache.cc
@@ -14,6 +14,7 @@
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/worker_pool.h"
#include "base/time/time.h"
@@ -205,10 +206,8 @@ Thumbnail* ThumbnailCache::Get(TabId tab_id,
}
if (force_disk_read &&
- std::find(visible_ids_.begin(), visible_ids_.end(), tab_id) !=
- visible_ids_.end() &&
- std::find(read_queue_.begin(), read_queue_.end(), tab_id) ==
- read_queue_.end()) {
+ ContainsValue(visible_ids_, tab_id) &&
+ !ContainsValue(read_queue_, tab_id)) {
read_queue_.push_back(tab_id);
ReadNextThumbnail();
}
@@ -305,8 +304,7 @@ void ThumbnailCache::UpdateVisibleIds(const TabIdList& priority) {
TabId tab_id = *iter;
visible_ids_.push_back(tab_id);
if (!cache_.Get(tab_id) &&
- std::find(read_queue_.begin(), read_queue_.end(), tab_id) ==
- read_queue_.end()) {
+ !ContainsValue(read_queue_, tab_id)) {
read_queue_.push_back(tab_id);
}
iter++;
@@ -430,8 +428,7 @@ void ThumbnailCache::ReadNextThumbnail() {
void ThumbnailCache::MakeSpaceForNewItemIfNecessary(TabId tab_id) {
if (cache_.Get(tab_id) ||
- std::find(visible_ids_.begin(), visible_ids_.end(), tab_id) ==
- visible_ids_.end() ||
+ !ContainsValue(visible_ids_, tab_id) ||
cache_.size() < cache_.MaximumCacheSize()) {
return;
}
@@ -443,8 +440,7 @@ void ThumbnailCache::MakeSpaceForNewItemIfNecessary(TabId tab_id) {
for (ExpiringThumbnailCache::iterator iter = cache_.begin();
iter != cache_.end();
iter++) {
- if (std::find(visible_ids_.begin(), visible_ids_.end(), iter->first) ==
- visible_ids_.end()) {
+ if (!ContainsValue(visible_ids_, iter->first)) {
key_to_remove = iter->first;
found_key_to_remove = true;
break;

Powered by Google App Engine
This is Rietveld 408576698