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

Unified Diff: chrome/browser/history/top_sites_cache.cc

Issue 4106014: Tweaks to improve memory consumption by TopSites. The biggest culprit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 10 years, 2 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
« no previous file with comments | « chrome/browser/history/top_sites_cache.h ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_cache.cc
diff --git a/chrome/browser/history/top_sites_cache.cc b/chrome/browser/history/top_sites_cache.cc
index 9bae92878cbee6322d0d2f8a98277d2fba3b38ac..828b701468b8b8645b497dbbf7ae96dcda540654 100644
--- a/chrome/browser/history/top_sites_cache.cc
+++ b/chrome/browser/history/top_sites_cache.cc
@@ -48,17 +48,17 @@ bool TopSitesCache::GetPageThumbnail(const GURL& url,
}
GURL TopSitesCache::GetCanonicalURL(const GURL& url) {
- std::map<GURL, size_t>::const_iterator i = canonical_urls_.find(url);
- return i == canonical_urls_.end() ? url : top_sites_[i->second].url;
+ CanonicalURLs::iterator i = TopSitesCache::GetCanonicalURLsIterator(url);
+ return i == canonical_urls_.end() ? url : i->first.first->url;
}
bool TopSitesCache::IsKnownURL(const GURL& url) {
- return canonical_urls_.find(url) != canonical_urls_.end();
+ return GetCanonicalURLsIterator(url) != canonical_urls_.end();
}
size_t TopSitesCache::GetURLIndex(const GURL& url) {
DCHECK(IsKnownURL(url));
- return canonical_urls_[url];
+ return GetCanonicalURLsIterator(url)->second;
}
void TopSitesCache::RemoveUnreferencedThumbnails() {
@@ -88,9 +88,23 @@ void TopSitesCache::StoreRedirectChain(const RedirectList& redirects,
// Map all the redirected URLs to the destination.
for (size_t i = 0; i < redirects.size(); i++) {
// If this redirect is already known, don't replace it with a new one.
- if (canonical_urls_.find(redirects[i]) == canonical_urls_.end())
- canonical_urls_[redirects[i]] = destination;
+ if (!IsKnownURL(redirects[i])) {
+ CanonicalURLEntry entry;
+ entry.first = &(top_sites_[destination]);
+ entry.second = i;
+ canonical_urls_[entry] = destination;
+ }
}
}
+TopSitesCache::CanonicalURLs::iterator TopSitesCache::GetCanonicalURLsIterator(
+ const GURL& url) {
+ MostVisitedURL most_visited_url;
+ most_visited_url.redirects.push_back(url);
+ CanonicalURLEntry entry;
+ entry.first = &most_visited_url;
+ entry.second = 0u;
+ return canonical_urls_.find(entry);
+}
+
} // namespace history
« no previous file with comments | « chrome/browser/history/top_sites_cache.h ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698