Commit da17c63f authored by DongJun Kim's avatar DongJun Kim Committed by Commit Bot

Use ContainsValue() instead of std::find() in components/autofill #2

autofill : Use ContainsValue() instead of std::find() in components/autofill
This simplifies many conditions around the code.

Bug: 561800
Change-Id: I36579da9e0e62fbf834a39419c9bc253546fec24
Reviewed-on: https://chromium-review.googlesource.com/1183268
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584727}
parent 1de68d73
......@@ -10,6 +10,7 @@
#include "base/containers/flat_set.h"
#include "base/i18n/case_conversion.h"
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
......@@ -240,12 +241,9 @@ void FindWordsFromCategoryInForm(
}
}
if (fields_found > 0 && fields_found <= 2) {
if (std::find(username_predictions->begin(), username_predictions->end(),
chosen_field) == username_predictions->end()) {
if (fields_found > 0 && fields_found <= 2)
if (!base::ContainsValue(*username_predictions, chosen_field))
username_predictions->push_back(chosen_field);
}
}
}
// Find username elements if there is no cached result for the given form and
......
......@@ -197,9 +197,8 @@ std::vector<FormInputCollection> ExtractFormsForAnalysis(
// to be username or password fields.
if (input.TagName() == "INPUT" &&
(!input.HasAttribute("type") ||
std::find(std::begin(kTypeAttributes), std::end(kTypeAttributes),
input.GetAttribute("type").Utf8()) !=
std::end(kTypeAttributes))) {
base::ContainsValue(kTypeAttributes,
input.GetAttribute("type").Utf8()))) {
form_input_collections.back().AddInput(input);
inputs_with_forms.insert(input);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment