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

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

Issue 1665023002: Cheer up spell-checking code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More descriptive variable name Created 4 years, 10 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 | « no previous file | chrome/browser/spellchecker/feedback_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellchecker/feedback.cc
diff --git a/chrome/browser/spellchecker/feedback.cc b/chrome/browser/spellchecker/feedback.cc
index 17bc4b7e60b46b9e14e6ea4a13f20c11c2e1aa01..cfc4a711b3c9ced53944247a8933b5fd938bd325 100644
--- a/chrome/browser/spellchecker/feedback.cc
+++ b/chrome/browser/spellchecker/feedback.cc
@@ -35,7 +35,7 @@ Feedback::~Feedback() {}
Misspelling* Feedback::GetMisspelling(uint32_t hash) {
HashMisspellingMap::iterator misspelling_it = misspellings_.find(hash);
if (misspelling_it == misspellings_.end())
- return NULL;
+ return nullptr;
return &misspelling_it->second;
}
@@ -49,12 +49,11 @@ void Feedback::FinalizeRemovedMisspellings(
HashCollection& renderer_hashes = renderer_it->second;
HashCollection remaining_hashes(remaining_markers.begin(),
remaining_markers.end());
- std::vector<uint32_t> removed_hashes =
- base::STLSetDifference<std::vector<uint32_t>>(renderer_hashes,
- remaining_hashes);
- for (std::vector<uint32_t>::const_iterator hash_it = removed_hashes.begin();
- hash_it != removed_hashes.end(); ++hash_it) {
- HashMisspellingMap::iterator misspelling_it = misspellings_.find(*hash_it);
+ std::vector<HashCollection::value_type> removed_hashes =
+ base::STLSetDifference<std::vector<HashCollection::value_type>>(
+ renderer_hashes, remaining_hashes);
+ for (auto hash : removed_hashes) {
+ HashMisspellingMap::iterator misspelling_it = misspellings_.find(hash);
if (misspelling_it != misspellings_.end() &&
!misspelling_it->second.action.IsFinal()) {
misspelling_it->second.action.Finalize();
@@ -157,29 +156,24 @@ bool Feedback::Empty() const {
std::vector<int> Feedback::GetRendersWithMisspellings() const {
std::vector<int> renderers_with_misspellings;
- for (RendererHashesMap::const_iterator renderer_it = renderers_.begin();
- renderer_it != renderers_.end(); ++renderer_it) {
- if (!renderer_it->second.empty())
- renderers_with_misspellings.push_back(renderer_it->first);
+ for (const auto& renderer : renderers_) {
+ if (!renderer.second.empty())
+ renderers_with_misspellings.push_back(renderer.first);
}
return renderers_with_misspellings;
}
void Feedback::FinalizeAllMisspellings() {
- for (HashMisspellingMap::iterator misspelling_it = misspellings_.begin();
- misspelling_it != misspellings_.end(); ++misspelling_it) {
- if (!misspelling_it->second.action.IsFinal())
- misspelling_it->second.action.Finalize();
+ for (auto& misspelling : misspellings_) {
+ if (!misspelling.second.action.IsFinal())
+ misspelling.second.action.Finalize();
}
}
std::vector<Misspelling> Feedback::GetAllMisspellings() const {
std::vector<Misspelling> all_misspellings;
- for (HashMisspellingMap::const_iterator misspelling_it =
- misspellings_.begin();
- misspelling_it != misspellings_.end(); ++misspelling_it) {
- all_misspellings.push_back(misspelling_it->second);
- }
+ for (const auto& misspelling : misspellings_)
+ all_misspellings.push_back(misspelling.second);
return all_misspellings;
}
« no previous file with comments | « no previous file | chrome/browser/spellchecker/feedback_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698