Skip to content

Commit

Permalink
[Autofill] Use set instead of map for phone number rationalized sections
Browse files Browse the repository at this point in the history
Bug: 1007974
Change-Id: I5c7273947a9380c918edd14824dd335248166004
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3810567
Reviewed-by: Florian Leimgruber <fleimgruber@google.com>
Reviewed-by: Christoph Schwering <schwering@google.com>
Commit-Queue: Eva Herencsarova <evih@google.com>
Cr-Commit-Position: refs/heads/main@{#1032476}
  • Loading branch information
Eva Herencsarova authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 6fb3f11 commit 15bc781
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/autofill/core/browser/form_structure.cc
Expand Up @@ -1596,7 +1596,7 @@ void FormStructure::RationalizeStreetAddressAndAddressLine(
}

void FormStructure::RationalizePhoneNumbersInSection(const Section& section) {
if (phone_rationalized_[section])
if (base::Contains(phone_rationalized_, section))
return;
std::vector<AutofillField*> fields;
for (size_t i = 0; i < field_count(); ++i) {
Expand All @@ -1605,7 +1605,7 @@ void FormStructure::RationalizePhoneNumbersInSection(const Section& section) {
fields.push_back(field(i));
}
rationalization_util::RationalizePhoneNumberFields(fields);
phone_rationalized_[section] = true;
phone_rationalized_.insert(section);
}

void FormStructure::ApplyRationalizationsToFieldAndLog(
Expand Down
3 changes: 1 addition & 2 deletions components/autofill/core/browser/form_structure.h
Expand Up @@ -7,7 +7,6 @@

#include <stddef.h>

#include <map>
#include <memory>
#include <set>
#include <string>
Expand Down Expand Up @@ -669,7 +668,7 @@ class FormStructure {
base::TimeTicks form_parsed_timestamp_;

// If phone number rationalization has been performed for a given section.
std::map<Section, bool> phone_rationalized_;
std::set<Section> phone_rationalized_;

// True iff the form is a password form and the user has seen the password
// value before accepting the prompt to save. Used for crowdsourcing.
Expand Down
4 changes: 2 additions & 2 deletions components/autofill/core/browser/form_structure_test_api.h
Expand Up @@ -7,6 +7,7 @@

#include <string>

#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "components/autofill/core/browser/form_structure.h"
Expand Down Expand Up @@ -67,8 +68,7 @@ class FormStructureTestApi {
}

bool phone_rationalized(const Section& section) const {
auto it = form_structure_->phone_rationalized_.find(section);
return it != form_structure_->phone_rationalized_.end() && it->second;
return base::Contains(form_structure_->phone_rationalized_, section);
}

void ParseFieldTypesWithPatterns(PatternSource pattern_source) {
Expand Down

0 comments on commit 15bc781

Please sign in to comment.