OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/omnibox/browser/url_index_private_data.h" | 5 #include "components/omnibox/browser/url_index_private_data.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <functional> | 9 #include <functional> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 if (pre_filter_item_count_ > post_filter_item_count_) { | 246 if (pre_filter_item_count_ > post_filter_item_count_) { |
247 // If we trim the results set we do not want to cache the results for next | 247 // If we trim the results set we do not want to cache the results for next |
248 // time as the user's ultimately desired result could easily be eliminated | 248 // time as the user's ultimately desired result could easily be eliminated |
249 // in the early rough filter. | 249 // in the early rough filter. |
250 search_term_cache_.clear(); | 250 search_term_cache_.clear(); |
251 } else { | 251 } else { |
252 // Remove any stale SearchTermCacheItems. | 252 // Remove any stale SearchTermCacheItems. |
253 for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin(); | 253 for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin(); |
254 cache_iter != search_term_cache_.end(); ) { | 254 cache_iter != search_term_cache_.end(); ) { |
255 if (!cache_iter->second.used_) | 255 if (!cache_iter->second.used_) |
256 search_term_cache_.erase(cache_iter++); | 256 cache_iter = search_term_cache_.erase(cache_iter); |
Peter Kasting
2016/11/29 19:17:45
FWIW, now that C++11 provides this on std::map, we
dyaroshev
2016/11/29 20:09:14
Some time ago there was a problem with the standar
Peter Kasting
2016/11/29 20:29:06
I don't either.
| |
257 else | 257 else |
258 ++cache_iter; | 258 ++cache_iter; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 return scored_items; | 262 return scored_items; |
263 } | 263 } |
264 | 264 |
265 bool URLIndexPrivateData::UpdateURL( | 265 bool URLIndexPrivateData::UpdateURL( |
266 history::HistoryService* history_service, | 266 history::HistoryService* history_service, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 word_id_set, leftover_set); | 598 word_id_set, leftover_set); |
599 word_id_set.swap(new_word_id_set); | 599 word_id_set.swap(new_word_id_set); |
600 } | 600 } |
601 } | 601 } |
602 | 602 |
603 // We must filter the word list because the resulting word set surely | 603 // We must filter the word list because the resulting word set surely |
604 // contains words which do not have the search term as a proper subset. | 604 // contains words which do not have the search term as a proper subset. |
605 for (WordIDSet::iterator word_set_iter = word_id_set.begin(); | 605 for (WordIDSet::iterator word_set_iter = word_id_set.begin(); |
606 word_set_iter != word_id_set.end(); ) { | 606 word_set_iter != word_id_set.end(); ) { |
607 if (word_list_[*word_set_iter].find(term) == base::string16::npos) | 607 if (word_list_[*word_set_iter].find(term) == base::string16::npos) |
608 word_id_set.erase(word_set_iter++); | 608 word_set_iter = word_id_set.erase(word_set_iter); |
609 else | 609 else |
610 ++word_set_iter; | 610 ++word_set_iter; |
611 } | 611 } |
612 } else { | 612 } else { |
613 word_id_set = WordIDSetForTermChars(Char16SetFromString16(term)); | 613 word_id_set = WordIDSetForTermChars(Char16SetFromString16(term)); |
614 } | 614 } |
615 | 615 |
616 // If any words resulted then we can compose a set of history IDs by unioning | 616 // If any words resulted then we can compose a set of history IDs by unioning |
617 // the sets from each word. | 617 // the sets from each word. |
618 HistoryIDSet history_id_set; | 618 HistoryIDSet history_id_set; |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1382 // First cut: typed count, visit count, recency. | 1382 // First cut: typed count, visit count, recency. |
1383 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1383 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
1384 // recently visited (within the last 12/24 hours) as highly important. Get | 1384 // recently visited (within the last 12/24 hours) as highly important. Get |
1385 // input from mpearson. | 1385 // input from mpearson. |
1386 if (r1.typed_count() != r2.typed_count()) | 1386 if (r1.typed_count() != r2.typed_count()) |
1387 return (r1.typed_count() > r2.typed_count()); | 1387 return (r1.typed_count() > r2.typed_count()); |
1388 if (r1.visit_count() != r2.visit_count()) | 1388 if (r1.visit_count() != r2.visit_count()) |
1389 return (r1.visit_count() > r2.visit_count()); | 1389 return (r1.visit_count() > r2.visit_count()); |
1390 return (r1.last_visit() > r2.last_visit()); | 1390 return (r1.last_visit() > r2.last_visit()); |
1391 } | 1391 } |
OLD | NEW |