Chromium Code Reviews| Index: chrome/browser/spellchecker/feedback.cc |
| diff --git a/chrome/browser/spellchecker/feedback.cc b/chrome/browser/spellchecker/feedback.cc |
| index 7e6ce5fb58af2886d1cd4bc2e81b099cc05f722a..69530e7e098fe5d49cd671f7f1c5d86af28700f9 100644 |
| --- a/chrome/browser/spellchecker/feedback.cc |
| +++ b/chrome/browser/spellchecker/feedback.cc |
| @@ -6,7 +6,6 @@ |
| #include <algorithm> |
| #include <iterator> |
| -#include <set> |
| namespace spellcheck { |
| @@ -17,7 +16,7 @@ Feedback::~Feedback() { |
| } |
| Misspelling* Feedback::GetMisspelling(uint32 hash) { |
| - std::map<uint32, Misspelling>::iterator it = misspellings_.find(hash); |
| + HashMisspellingMap::iterator it = misspellings_.find(hash); |
| if (it == misspellings_.end()) |
| return NULL; |
| return &it->second; |
| @@ -26,45 +25,41 @@ Misspelling* Feedback::GetMisspelling(uint32 hash) { |
| void Feedback::FinalizeRemovedMisspellings( |
| int renderer_process_id, |
| const std::vector<uint32>& remaining_markers) { |
| - std::map<int, std::vector<uint32> >::iterator i = |
| - hashes_.find(renderer_process_id); |
| + RendererHashesMap::iterator i = hashes_.find(renderer_process_id); |
| if (i == hashes_.end() || i->second.empty()) |
| return; |
| - std::vector<uint32> remaining_copy(remaining_markers); |
| - std::sort(remaining_copy.begin(), remaining_copy.end()); |
| - std::sort(i->second.begin(), i->second.end()); |
| + std::set<uint32> remaining_set(remaining_markers.begin(), |
|
groby-ooo-7-16
2013/05/23 19:10:50
Isn't that a HashCollection now?
please use gerrit instead
2013/05/23 19:54:54
Yep, it is. Fixed.
|
| + remaining_markers.end()); |
| std::vector<uint32> removed_markers; |
| std::set_difference(i->second.begin(), |
| i->second.end(), |
| - remaining_copy.begin(), |
| - remaining_copy.end(), |
| + remaining_set.begin(), |
| + remaining_set.end(), |
| std::back_inserter(removed_markers)); |
| for (std::vector<uint32>::const_iterator j = removed_markers.begin(); |
| j != removed_markers.end(); |
| ++j) { |
| - std::map<uint32, Misspelling>::iterator k = misspellings_.find(*j); |
| + HashMisspellingMap::iterator k = misspellings_.find(*j); |
| if (k != misspellings_.end() && !k->second.action.IsFinal()) |
| k->second.action.Finalize(); |
| } |
| } |
| bool Feedback::RendererHasMisspellings(int renderer_process_id) const { |
| - std::map<int, std::vector<uint32> >::const_iterator it = |
| - hashes_.find(renderer_process_id); |
| + RendererHashesMap::const_iterator it = hashes_.find(renderer_process_id); |
| return it != hashes_.end() && !it->second.empty(); |
| } |
| std::vector<Misspelling> Feedback::GetMisspellingsInRenderer( |
| int renderer_process_id) const { |
| std::vector<Misspelling> result; |
| - std::map<int, std::vector<uint32> >::const_iterator i = |
| - hashes_.find(renderer_process_id); |
| + RendererHashesMap::const_iterator i = hashes_.find(renderer_process_id); |
| if (i == hashes_.end() || i->second.empty()) |
| return result; |
| - for (std::vector<uint32>::const_iterator j = i->second.begin(); |
| + for (HashCollection::const_iterator j = i->second.begin(); |
| j != i->second.end(); |
| ++j) { |
| - std::map<uint32, Misspelling>::const_iterator k = misspellings_.find(*j); |
| + HashMisspellingMap::const_iterator k = misspellings_.find(*j); |
| if (k != misspellings_.end()) |
| result.push_back(k->second); |
| } |
| @@ -72,20 +67,19 @@ std::vector<Misspelling> Feedback::GetMisspellingsInRenderer( |
| } |
| void Feedback::EraseFinalizedMisspellings(int renderer_process_id) { |
| - std::map<int, std::vector<uint32> >::iterator i = |
| - hashes_.find(renderer_process_id); |
| + RendererHashesMap::iterator i = hashes_.find(renderer_process_id); |
| if (i == hashes_.end() || i->second.empty()) |
| return; |
| - std::vector<uint32> pending; |
| - for (std::vector<uint32>::const_iterator j = i->second.begin(); |
| + HashCollection pending; |
| + for (HashCollection::const_iterator j = i->second.begin(); |
| j != i->second.end(); |
| ++j) { |
| - std::map<uint32, Misspelling>::iterator k = misspellings_.find(*j); |
| + HashMisspellingMap::iterator k = misspellings_.find(*j); |
| if (k != misspellings_.end()) { |
| if (k->second.action.IsFinal()) |
| misspellings_.erase(k); |
| else |
| - pending.push_back(*j); |
| + pending.insert(*j); |
| } |
| } |
| i->second.swap(pending); |
| @@ -98,7 +92,7 @@ bool Feedback::HasMisspelling(uint32 hash) const { |
| void Feedback::AddMisspelling(int renderer_process_id, |
| const Misspelling& misspelling) { |
| misspellings_[misspelling.hash] = misspelling; |
| - hashes_[renderer_process_id].push_back(misspelling.hash); |
| + hashes_[renderer_process_id].insert(misspelling.hash); |
| } |
| bool Feedback::Empty() const { |
| @@ -107,7 +101,7 @@ bool Feedback::Empty() const { |
| std::vector<int> Feedback::GetRendersWithMisspellings() const { |
| std::vector<int> result; |
| - for (std::map<int, std::vector<uint32> >::const_iterator it = hashes_.begin(); |
| + for (RendererHashesMap::const_iterator it = hashes_.begin(); |
| it != hashes_.end(); |
| ++it) { |
| if (!it->second.empty()) |
| @@ -117,7 +111,7 @@ std::vector<int> Feedback::GetRendersWithMisspellings() const { |
| } |
| void Feedback::FinalizeAllMisspellings() { |
| - for (std::map<uint32, Misspelling>::iterator it = misspellings_.begin(); |
| + for (HashMisspellingMap::iterator it = misspellings_.begin(); |
| it != misspellings_.end(); |
| ++it) { |
| if (!it->second.action.IsFinal()) |
| @@ -127,7 +121,7 @@ void Feedback::FinalizeAllMisspellings() { |
| std::vector<Misspelling> Feedback::GetAllMisspellings() const { |
| std::vector<Misspelling> result; |
| - for (std::map<uint32, Misspelling>::const_iterator it = misspellings_.begin(); |
| + for (HashMisspellingMap::const_iterator it = misspellings_.begin(); |
| it != misspellings_.end(); |
| ++it) { |
| result.push_back(it->second); |