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

Unified Diff: chrome/browser/spellchecker/spellcheck_service.cc

Issue 1830543003: Using STL to implement functionality in input_method_util.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/spellchecker/spellcheck_service.cc
diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc
index 7360f061548efc9d4258c6ee0d3eac1bec9a3719..374fa2f23e4c4e0d7c5c209b8ce671306581b5a8 100644
--- a/chrome/browser/spellchecker/spellcheck_service.cc
+++ b/chrome/browser/spellchecker/spellcheck_service.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/spellchecker/spellcheck_service.h"
+#include <algorithm>
#include <set>
#include "base/logging.h"
@@ -353,12 +354,11 @@ void SpellcheckService::OnAcceptLanguagesChanged() {
std::vector<std::string> dictionaries = dictionaries_pref.GetValue();
std::vector<std::string> filtered_dictionaries;
- for (const auto& dictionary : dictionaries) {
- if (std::find(accept_languages.begin(), accept_languages.end(),
- dictionary) != accept_languages.end()) {
- filtered_dictionaries.push_back(dictionary);
- }
- }
+ std::sort(dictionaries.begin(), dictionaries.end());
groby-ooo-7-16 2016/04/04 22:30:40 Before modifying things, please check the history
chakshu 2016/04/11 06:54:37 Thank you for the review. Using unordered_set wil
+ std::sort(accept_languages.begin(), accept_languages.end());
+ std::set_intersection(dictionaries.begin(), dictionaries.end(),
+ accept_languages.begin(), accept_languages.end(),
+ std::back_inserter(filtered_dictionaries));
dictionaries_pref.SetValue(filtered_dictionaries);
}

Powered by Google App Engine
This is Rietveld 408576698