Chromium Code Reviews| 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); |
| } |