Don't assume STL iterators are pointers
This is batch 1 of a Chromium-wide cleanup preparing for a libc++ change that changes various iterators to not be raw pointers. components/omnibox/browser/autocomplete_result_unittest.cc was refactored to use base::span in AssertResultMatches(). AX-Relnotes: n/a. Bug: 328308661 Change-Id: I77e74d10ae0a616b9086d712476d712cd31ccb3e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5350511 Owners-Override: Nico Weber <thakis@chromium.org> Commit-Queue: Arthur Eubanks <aeubanks@google.com> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1269423}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
27ad2c4c69
commit
2af5aee58a
base/ranges
chrome
browser
enterprise
connectors
reporting
extensions
new_tab_page
chrome_colors
sync
ui
color
webui
support_tool
common
components
autofill
core
browser
data_model
autofill_i18n_api.ccautofill_i18n_api_unittest.ccautofill_structured_address_format_provider.cciban.cc
field_types.ccform_parsing
geo
manual_testing_import.ccmetrics
ui
common
browsing_data
content_settings
core
browser
headless
command_handler
manta
metrics
omnibox
password_manager
core
browser
import
policy
core
prefs
shared_highlighting
core
common
sync_preferences
url_pattern_index
user_manager
multi_user
content/renderer/accessibility/annotations
device/gamepad
extensions/browser/api/web_request
google_apis/calendar
media
net
pdf
services
device
compute_pressure
network
screen_ai
webnn
ui
accessibility
base
color
ozone
platform
wayland
views
@ -49,7 +49,7 @@ template <size_t N>
|
||||
constexpr std::array<int, N> GenerateArray() {
|
||||
std::array<int, N> arr{};
|
||||
int i = 0;
|
||||
for (auto* it = ranges::begin(arr); it != ranges::end(arr); ++it) {
|
||||
for (auto it = ranges::begin(arr); it != ranges::end(arr); ++it) {
|
||||
*it = i++;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ TEST(RangesTest, BeginConstexprContainers) {
|
||||
static_assert(il.begin() == ranges::begin(il), "");
|
||||
|
||||
static constexpr std::array<int, 3> array = {1, 2, 3};
|
||||
static_assert(&array[0] == ranges::begin(array), "");
|
||||
static_assert(array.begin() == ranges::begin(array), "");
|
||||
}
|
||||
|
||||
TEST(RangesTest, BeginRegularContainers) {
|
||||
@ -95,7 +95,7 @@ TEST(RangesTest, EndConstexprContainers) {
|
||||
static_assert(il.end() == ranges::end(il), "");
|
||||
|
||||
static constexpr std::array<int, 3> array = {1, 2, 3};
|
||||
static_assert(&array[0] + 3 == ranges::end(array), "");
|
||||
static_assert(array.begin() + 3 == ranges::end(array), "");
|
||||
}
|
||||
|
||||
TEST(RangesTest, EndRegularContainers) {
|
||||
|
@ -8,7 +8,7 @@ namespace enterprise_connectors {
|
||||
|
||||
EnterpriseReportingEventType GetUmaEnumFromEventName(
|
||||
const base::StringPiece& eventName) {
|
||||
auto* it = kEventNameToUmaEnumMap.find(eventName);
|
||||
auto it = kEventNameToUmaEnumMap.find(eventName);
|
||||
return it != kEventNameToUmaEnumMap.end()
|
||||
? it->second
|
||||
: EnterpriseReportingEventType::kUnknownEvent;
|
||||
|
@ -558,7 +558,7 @@ CWSInfoService::CWSViolationType CWSInfoService::GetViolationTypeFromString(
|
||||
{"minor-policy-violation",
|
||||
CWSInfoService::CWSViolationType::kMinorPolicy}});
|
||||
|
||||
const auto* it = violation_type_str_map.find(violation_type_str);
|
||||
const auto it = violation_type_str_map.find(violation_type_str);
|
||||
return it != violation_type_str_map.end() ? it->second
|
||||
: CWSViolationType::kUnknown;
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ enum class ChromeColorType {
|
||||
|
||||
int GetDynamicColorId(const SkColor color,
|
||||
ui::mojom::BrowserColorVariant variant) {
|
||||
auto* it = base::ranges::find_if(kDynamicCustomizeChromeColors,
|
||||
[&](const DynamicColorInfo& dynamic_color) {
|
||||
return dynamic_color.color == color &&
|
||||
dynamic_color.variant == variant;
|
||||
});
|
||||
auto it = base::ranges::find_if(kDynamicCustomizeChromeColors,
|
||||
[&](const DynamicColorInfo& dynamic_color) {
|
||||
return dynamic_color.color == color &&
|
||||
dynamic_color.variant == variant;
|
||||
});
|
||||
return it == kDynamicCustomizeChromeColors.end() ? kOtherDynamicColorId
|
||||
: it->id;
|
||||
}
|
||||
|
@ -1427,7 +1427,7 @@ constexpr auto kChromeSyncablePrefsAllowlist = base::MakeFixedFlatMap<
|
||||
std::optional<sync_preferences::SyncablePrefMetadata>
|
||||
ChromeSyncablePrefsDatabase::GetSyncablePrefMetadata(
|
||||
const std::string& pref_name) const {
|
||||
const auto* it = kChromeSyncablePrefsAllowlist.find(pref_name);
|
||||
const auto it = kChromeSyncablePrefsAllowlist.find(pref_name);
|
||||
if (it != kChromeSyncablePrefsAllowlist.end()) {
|
||||
DCHECK(!common_syncable_prefs_database_.GetSyncablePrefMetadata(pref_name)
|
||||
.has_value());
|
||||
|
@ -41,7 +41,7 @@ bool ChromeColorProviderUtilsCallbacks::ColorIdName(
|
||||
base::StringPiece* color_name) {
|
||||
static constexpr const auto chrome_color_id_map =
|
||||
base::MakeFixedFlatMap<ui::ColorId, const char*>({CHROME_COLOR_IDS});
|
||||
auto* i = chrome_color_id_map.find(color_id);
|
||||
auto i = chrome_color_id_map.find(color_id);
|
||||
if (i != chrome_color_id_map.cend()) {
|
||||
*color_name = i->second;
|
||||
return true;
|
||||
|
@ -21,7 +21,7 @@
|
||||
std::string ChromeColorIdName(ui::ColorId color_id) {
|
||||
static constexpr const auto color_id_map =
|
||||
base::MakeFixedFlatMap<ui::ColorId, const char*>({CHROME_COLOR_IDS});
|
||||
auto* i = color_id_map.find(color_id);
|
||||
auto i = color_id_map.find(color_id);
|
||||
DCHECK(i != color_id_map.cend());
|
||||
return {i->second};
|
||||
}
|
||||
|
@ -103,10 +103,7 @@ class SupportToolUiUtilsTest : public ::testing::Test {
|
||||
{redaction::PIIType::kURL, IDS_SUPPORT_TOOL_URLS},
|
||||
{redaction::PIIType::kStableIdentifier,
|
||||
IDS_SUPPORT_TOOL_STABLE_IDENTIDIERS}});
|
||||
// fixed_flat_map uses std::array<T> as the backing container, which has
|
||||
// std::array::iterator<T> = T*, thus the iterator of the
|
||||
// `kExpectedPiiTypeDefinitions` is a pointer.
|
||||
auto* it = kExpectedPiiTypeDefinitions.find(pii_type);
|
||||
auto it = kExpectedPiiTypeDefinitions.find(pii_type);
|
||||
EXPECT_NE(kExpectedPiiTypeDefinitions.end(), it);
|
||||
std::string definition = l10n_util::GetStringUTF8(it->second);
|
||||
return definition;
|
||||
|
@ -523,10 +523,7 @@ constexpr auto kOidStringMap = base::MakeFixedFlatMap<bssl::der::Input, int>({
|
||||
});
|
||||
|
||||
std::optional<std::string> GetOidText(bssl::der::Input oid) {
|
||||
// TODO(crbug.com/1311404): this should be "const auto i" since it's an
|
||||
// iterator, but fixed_flat_map iterators are raw pointers and the
|
||||
// chromium-style plugin complains.
|
||||
const auto* i = kOidStringMap.find(oid);
|
||||
const auto i = kOidStringMap.find(oid);
|
||||
if (i != kOidStringMap.end())
|
||||
return l10n_util::GetStringUTF8(i->second);
|
||||
return std::nullopt;
|
||||
|
@ -247,7 +247,7 @@ TreeEdgesList GetTreeEdges(AddressCountryCode country_code) {
|
||||
->second;
|
||||
}
|
||||
|
||||
auto* it = kAutofillModelRules.find(country_code.value());
|
||||
auto it = kAutofillModelRules.find(country_code.value());
|
||||
|
||||
// If the entry is not defined, use the legacy rules.
|
||||
return it == kAutofillModelRules.end()
|
||||
@ -299,7 +299,7 @@ std::u16string GetFormattingExpression(FieldType field_type,
|
||||
// expression if they exist. Note that it should not fallback to a legacy
|
||||
// expression, as these ones refer to a different hierarchy.
|
||||
if (IsCustomHierarchyAvailableForCountry(country_code)) {
|
||||
auto* it =
|
||||
auto it =
|
||||
kAutofillFormattingRulesMap.find({country_code.value(), field_type});
|
||||
|
||||
return it != kAutofillFormattingRulesMap.end()
|
||||
@ -308,7 +308,7 @@ std::u16string GetFormattingExpression(FieldType field_type,
|
||||
}
|
||||
|
||||
// Otherwise return a legacy formatting expression that exists.
|
||||
auto* legacy_it = kAutofillFormattingRulesMap.find(
|
||||
auto legacy_it = kAutofillFormattingRulesMap.find(
|
||||
{kLegacyHierarchyCountryCode.value(), field_type});
|
||||
return legacy_it != kAutofillFormattingRulesMap.end()
|
||||
? std::u16string(legacy_it->second)
|
||||
@ -333,7 +333,7 @@ i18n_model_definition::ValueParsingResults ParseValueByI18nRegularExpression(
|
||||
? country_code
|
||||
: kLegacyHierarchyCountryCode;
|
||||
|
||||
auto* it = kAutofillParsingRulesMap.find(
|
||||
auto it = kAutofillParsingRulesMap.find(
|
||||
{country_code_for_parsing.value(), field_type});
|
||||
return it != kAutofillParsingRulesMap.end() ? it->second->Parse(value)
|
||||
: std::nullopt;
|
||||
@ -342,7 +342,7 @@ i18n_model_definition::ValueParsingResults ParseValueByI18nRegularExpression(
|
||||
std::optional<std::u16string_view> GetStopwordsExpression(
|
||||
FieldType field_type,
|
||||
AddressCountryCode country_code) {
|
||||
auto* it = kAutofillModelStopwords.find({country_code.value(), field_type});
|
||||
auto it = kAutofillModelStopwords.find({country_code.value(), field_type});
|
||||
if (it == kAutofillModelStopwords.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -359,7 +359,7 @@ bool IsTypeEnabledForCountry(FieldType field_type,
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* it = kAutofillModelRules.find(country_code.value());
|
||||
auto it = kAutofillModelRules.find(country_code.value());
|
||||
return base::ranges::any_of(
|
||||
it->second, [field_type](const FieldTypeDescription& description) {
|
||||
return description.field_type == field_type ||
|
||||
|
@ -153,7 +153,7 @@ TEST_F(AutofillI18nApiTest, GetFormattingExpressions) {
|
||||
|
||||
TEST_F(AutofillI18nApiTest, ParseValueByI18nRegularExpression) {
|
||||
std::string apt_str = "sala 10";
|
||||
auto* it = kAutofillParsingRulesMap.find({"BR", ADDRESS_HOME_APT});
|
||||
auto it = kAutofillParsingRulesMap.find({"BR", ADDRESS_HOME_APT});
|
||||
|
||||
ASSERT_TRUE(it != kAutofillParsingRulesMap.end());
|
||||
EXPECT_EQ(ParseValueByI18nRegularExpression(apt_str, ADDRESS_HOME_APT,
|
||||
|
@ -30,7 +30,7 @@ std::u16string GetHomeStreetAddressPattern(std::string_view country_code) {
|
||||
u"${ADDRESS_HOME_STREET_NAME} ${ADDRESS_HOME_HOUSE_NUMBER}"
|
||||
u"${ADDRESS_HOME_FLOOR;, ;º}${ADDRESS_HOME_APT_NUM;, ;ª}"}});
|
||||
|
||||
if (auto* it = kHomeStreetAddressCountryMap.find(country_code);
|
||||
if (auto it = kHomeStreetAddressCountryMap.find(country_code);
|
||||
it != kHomeStreetAddressCountryMap.end()) {
|
||||
return std::u16string(it->second);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static constexpr int kPrefixLength = 4;
|
||||
static constexpr int kSuffixLength = 4;
|
||||
|
||||
int GetIbanCountryToLength(std::string_view country_code) {
|
||||
auto* it = kCountryToIbanLength.find(country_code);
|
||||
auto it = kCountryToIbanLength.find(country_code);
|
||||
if (it == kCountryToIbanLength.end()) {
|
||||
return 0;
|
||||
}
|
||||
@ -236,7 +236,7 @@ bool Iban::IsValid(const std::u16string& value) {
|
||||
|
||||
// static
|
||||
bool Iban::IsIbanApplicableInCountry(const std::string& country_code) {
|
||||
auto* it = kCountryToIbanLength.find(country_code);
|
||||
auto it = kCountryToIbanLength.find(country_code);
|
||||
return it != kCountryToIbanLength.end();
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ std::string FieldTypeToString(FieldType type) {
|
||||
}
|
||||
|
||||
FieldType TypeNameToFieldType(std::string_view type_name) {
|
||||
auto* it = kTypeNameToFieldType.find(type_name);
|
||||
auto it = kTypeNameToFieldType.find(type_name);
|
||||
return it != kTypeNameToFieldType.end() ? it->second : UNKNOWN_TYPE;
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,8 @@ FieldType FieldCandidates::BestHeuristicType() const {
|
||||
type_scores[field_candidate.type] += field_candidate.score;
|
||||
}
|
||||
|
||||
const auto* best_type_iter = base::ranges::max_element(type_scores);
|
||||
const size_t index = std::distance(type_scores.cbegin(), best_type_iter);
|
||||
const auto best_type_iter = base::ranges::max_element(type_scores);
|
||||
const size_t index = std::distance(type_scores.begin(), best_type_iter);
|
||||
|
||||
return ToSafeFieldType(index, NO_SERVER_DATA);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ base::span<const MatchPatternRef> GetMatchPatterns(
|
||||
std::string_view name,
|
||||
std::string_view language_code,
|
||||
PatternSource pattern_source) {
|
||||
auto* it = kPatternMap.find(std::make_pair(name, language_code));
|
||||
auto it = kPatternMap.find(std::make_pair(name, language_code));
|
||||
if (!language_code.empty() && it == kPatternMap.end())
|
||||
it = kPatternMap.find(std::make_pair(name, ""));
|
||||
CHECK(it != kPatternMap.end());
|
||||
|
@ -209,7 +209,7 @@ bool AutofillCountry::IsAddressFieldSettingAccessible(
|
||||
}
|
||||
|
||||
bool AutofillCountry::IsAddressFieldRequired(FieldType field_type) const {
|
||||
auto* mapping_it = kRequiredFieldMapping.find(field_type);
|
||||
auto mapping_it = kRequiredFieldMapping.find(field_type);
|
||||
return mapping_it != kRequiredFieldMapping.end() &&
|
||||
(required_fields_for_address_import_ & mapping_it->second);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ std::optional<AutofillProfile::Source> GetProfileSourceFromDict(
|
||||
return AutofillProfile::Source::kLocalOrSyncable;
|
||||
}
|
||||
if (const std::string* source_value = dict.FindString(kKeySource)) {
|
||||
if (auto* it = kSourceMapping.find(*source_value);
|
||||
if (auto it = kSourceMapping.find(*source_value);
|
||||
it != kSourceMapping.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
@ -7957,7 +7957,7 @@ class AutofillMetricsCrossFrameFormTest : public AutofillMetricsTest {
|
||||
{CREDIT_CARD_VERIFICATION_CODE, 3}});
|
||||
|
||||
for (FieldType fill_type : fill_field_types) {
|
||||
auto* index_it = type_to_index.find(fill_type);
|
||||
auto index_it = type_to_index.find(fill_type);
|
||||
ASSERT_NE(index_it, type_to_index.end());
|
||||
FormFieldData& field = form_.fields[index_it->second];
|
||||
field.value = fill_type != CREDIT_CARD_VERIFICATION_CODE
|
||||
|
@ -99,7 +99,7 @@ int GetIconResourceID(Suggestion::Icon resource_name) {
|
||||
autofill::features::kAutofillEnableNewCardArtAndNetworkImages)
|
||||
? kNewCardArtAndNetworkDataResources
|
||||
: kDataResources;
|
||||
auto* it = kDataResource.find(resource_name);
|
||||
auto it = kDataResource.find(resource_name);
|
||||
return it == kDataResource.end() ? kResourceNotFoundId : it->second;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ bool ContactTypeHintMatchesFieldType(const std::string& token,
|
||||
// `value` matches any of them.
|
||||
std::optional<HtmlFieldType> ParseStandardizedAutocompleteAttribute(
|
||||
std::string_view value) {
|
||||
auto* it = kStandardizedAttributes.find(value);
|
||||
auto it = kStandardizedAttributes.find(value);
|
||||
return it != kStandardizedAttributes.end()
|
||||
? std::optional<HtmlFieldType>(it->second)
|
||||
: std::nullopt;
|
||||
@ -124,7 +124,7 @@ std::optional<HtmlFieldType> ParseProposedAutocompleteAttribute(
|
||||
{"username", HtmlFieldType::kEmail},
|
||||
});
|
||||
|
||||
auto* it = proposed_attributes.find(value);
|
||||
auto it = proposed_attributes.find(value);
|
||||
return it != proposed_attributes.end()
|
||||
? std::optional<HtmlFieldType>(it->second)
|
||||
: std::nullopt;
|
||||
@ -150,7 +150,7 @@ std::optional<HtmlFieldType> ParseNonStandarizedAutocompleteAttribute(
|
||||
{"upi-vpa", HtmlFieldType::kUpiVpa},
|
||||
});
|
||||
|
||||
auto* it = non_standardized_attributes.find(value);
|
||||
auto it = non_standardized_attributes.find(value);
|
||||
return it != non_standardized_attributes.end()
|
||||
? std::optional<HtmlFieldType>(it->second)
|
||||
: std::nullopt;
|
||||
|
@ -76,7 +76,7 @@ void AppendSyncTypesIfRequired(const base::Value& browsing_data_type,
|
||||
"added or removed. Please update `kDataToSyncTypesMap` above to include "
|
||||
"the new type and the sync types it maps to if this data is synced.");
|
||||
|
||||
const auto* it = kDataToSyncTypesMap.find(browsing_data_type.GetString());
|
||||
const auto it = kDataToSyncTypesMap.find(browsing_data_type.GetString());
|
||||
if (it == kDataToSyncTypesMap.end()) {
|
||||
return;
|
||||
}
|
||||
@ -147,7 +147,7 @@ std::optional<PolicyDataType> NameToPolicyDataType(
|
||||
PolicyDataType::kCachedImagesAndFiles},
|
||||
});
|
||||
|
||||
const auto* it = kNameToDataType.find(type_name);
|
||||
const auto it = kNameToDataType.find(type_name);
|
||||
if (it == kNameToDataType.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting) {
|
||||
static_cast<size_t>(ContentSettingsType::NUM_TYPES),
|
||||
"Update content settings histogram lookup");
|
||||
|
||||
auto* found = kHistogramValue.find(content_setting);
|
||||
auto found = kHistogramValue.find(content_setting);
|
||||
if (found != kHistogramValue.end()) {
|
||||
DCHECK_NE(found->second, -1)
|
||||
<< "Used for deprecated settings: " << static_cast<int>(found->first);
|
||||
|
@ -188,7 +188,7 @@ bool GetCommandDictAndOutputPaths(base::Value::Dict* commands,
|
||||
{FILE_PATH_LITERAL(".webp"), "webp"},
|
||||
});
|
||||
|
||||
auto* it = kImageFileTypes.find(extension);
|
||||
auto it = kImageFileTypes.find(extension);
|
||||
if (it == kImageFileTypes.cend()) {
|
||||
LOG(ERROR) << "Unsupported screenshot image file type: "
|
||||
<< path.FinalExtension();
|
||||
|
@ -36,7 +36,7 @@ std::optional<MantaStatusCode> MapServerFailureReasonToMantaStatusCode(
|
||||
{"RESOURCE_EXHAUSTED", MantaStatusCode::kResourceExhausted},
|
||||
{"PER_USER_QUOTA_EXCEEDED", MantaStatusCode::kPerUserQuotaExceeded},
|
||||
});
|
||||
const auto* iter = reason_map.find(reason);
|
||||
const auto iter = reason_map.find(reason);
|
||||
|
||||
return iter != reason_map.end() ? std::optional<MantaStatusCode>(iter->second)
|
||||
: std::nullopt;
|
||||
@ -52,7 +52,7 @@ std::optional<MantaStatusCode> MapServerStatusCodeToMantaStatusCode(
|
||||
{3 /*INVALID_ARGUMENT*/, MantaStatusCode::kInvalidInput},
|
||||
{8 /*RESOURCE_EXHAUSTED*/, MantaStatusCode::kResourceExhausted},
|
||||
});
|
||||
const auto* iter = code_map.find(server_status_code);
|
||||
const auto iter = code_map.find(server_status_code);
|
||||
|
||||
return iter != code_map.end() ? std::optional<MantaStatusCode>(iter->second)
|
||||
: std::nullopt;
|
||||
|
@ -50,7 +50,7 @@ std::optional<Tone> GetTone(const std::string& tone) {
|
||||
{"FREEFORM_WRITE", proto::RequestConfig::FREEFORM_WRITE},
|
||||
|
||||
});
|
||||
const auto* iter = tone_map.find(tone);
|
||||
const auto iter = tone_map.find(tone);
|
||||
|
||||
return iter != tone_map.end() ? std::optional<Tone>(iter->second)
|
||||
: std::nullopt;
|
||||
|
@ -143,7 +143,7 @@ SystemProfileProto_ComponentId CrxIdToComponentId(const std::string& app_id) {
|
||||
SystemProfileProto_ComponentId_SODA_JA_JP},
|
||||
});
|
||||
|
||||
const auto* result = kComponentMap.find(app_id);
|
||||
const auto result = kComponentMap.find(app_id);
|
||||
if (result == kComponentMap.end()) {
|
||||
return SystemProfileProto_ComponentId_UNKNOWN;
|
||||
}
|
||||
|
@ -185,10 +185,7 @@ class AutocompleteResultTest : public testing::Test {
|
||||
|
||||
// Asserts that |result| has |expected_count| matches matching |expected|.
|
||||
void AssertResultMatches(const AutocompleteResult& result,
|
||||
const TestData* expected,
|
||||
size_t expected_count);
|
||||
void AssertResultMatches(const AutocompleteResult& result,
|
||||
const std::vector<TestData>& expected);
|
||||
base::span<const TestData> expected);
|
||||
|
||||
void AssertMatch(AutocompleteMatch match,
|
||||
const TestData& expected_match_data,
|
||||
@ -273,17 +270,8 @@ ACMatches AutocompleteResultTest::PopulateAutocompleteMatches(
|
||||
|
||||
void AutocompleteResultTest::AssertResultMatches(
|
||||
const AutocompleteResult& result,
|
||||
const TestData* expected,
|
||||
size_t expected_count) {
|
||||
ASSERT_EQ(expected_count, result.size());
|
||||
for (size_t i = 0; i < expected_count; ++i)
|
||||
AssertMatch(*(result.begin() + i), expected[i], i);
|
||||
}
|
||||
|
||||
void AutocompleteResultTest::AssertResultMatches(
|
||||
const AutocompleteResult& result,
|
||||
const std::vector<TestData>& expected) {
|
||||
ASSERT_EQ(result.size(), expected.size());
|
||||
base::span<const TestData> expected) {
|
||||
ASSERT_EQ(expected.size(), result.size());
|
||||
for (size_t i = 0; i < expected.size(); ++i)
|
||||
AssertMatch(*(result.begin() + i), expected[i], i);
|
||||
}
|
||||
@ -342,7 +330,7 @@ void AutocompleteResultTest::RunTransferOldMatchesTest(
|
||||
current_result.SortAndCull(input, template_url_service_.get(),
|
||||
triggered_feature_service());
|
||||
|
||||
AssertResultMatches(current_result, expected, expected_size);
|
||||
AssertResultMatches(current_result, {expected, expected_size});
|
||||
}
|
||||
|
||||
void AutocompleteResultTest::SortMatchesAndVerifyOrder(
|
||||
@ -1434,7 +1422,7 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) {
|
||||
result.AppendMatches(matches);
|
||||
result.SortAndCull(input, template_url_service_.get(),
|
||||
triggered_feature_service());
|
||||
AssertResultMatches(result, data, 4);
|
||||
AssertResultMatches(result, data);
|
||||
}
|
||||
|
||||
{
|
||||
@ -1987,7 +1975,7 @@ TEST_F(AutocompleteResultTest, SortAndCullGroupSuggestionsByType) {
|
||||
{6, 3, 1100, false, {}, AutocompleteMatchType::BOOKMARK_TITLE},
|
||||
{5, 2, 1000, false, {}, AutocompleteMatchType::HISTORY_BODY},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2043,7 +2031,7 @@ TEST_F(AutocompleteResultTest, SortAndCull_DemoteSuggestionGroups_ExceedLimit) {
|
||||
// Group two is scored lower
|
||||
{2, 1, 700, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
{
|
||||
SCOPED_TRACE("Zero input");
|
||||
@ -2069,7 +2057,7 @@ TEST_F(AutocompleteResultTest, SortAndCull_DemoteSuggestionGroups_ExceedLimit) {
|
||||
{5, 2, 1000, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
{4, 1, 900, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
|
||||
// Set sections that contradict the scores of the matches in groups.
|
||||
@ -2101,7 +2089,7 @@ TEST_F(AutocompleteResultTest, SortAndCull_DemoteSuggestionGroups_ExceedLimit) {
|
||||
{5, 2, 1000, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
{4, 1, 900, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
{
|
||||
SCOPED_TRACE("Zero input, with explicit sections");
|
||||
@ -2128,7 +2116,7 @@ TEST_F(AutocompleteResultTest, SortAndCull_DemoteSuggestionGroups_ExceedLimit) {
|
||||
{2, 1, 700, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
{0, 4, 500, false, {}, AutocompleteMatchType::SEARCH_SUGGEST},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2168,8 +2156,9 @@ TEST_F(AutocompleteResultTest,
|
||||
{4, 1, 1000, false, {}, AutocompleteMatchType::HISTORY_URL},
|
||||
};
|
||||
|
||||
AssertResultMatches(result, expected_data,
|
||||
AutocompleteResult::GetMaxMatches());
|
||||
AssertResultMatches(
|
||||
result,
|
||||
{expected_data, expected_data + AutocompleteResult::GetMaxMatches()});
|
||||
}
|
||||
|
||||
TEST_F(AutocompleteResultTest, SortAndCullMaxHistoryClusterSuggestions) {
|
||||
@ -2715,7 +2704,7 @@ TEST_F(AutocompleteResultTest, Desktop_TwoColumnRealbox) {
|
||||
{3, 1, 470, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
{4, 1, 460, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
|
||||
// Verify that the secondary zero-prefix suggestions were not triggered.
|
||||
VerifyTriggeredFeatures(triggered_feature_service(), {});
|
||||
@ -2745,7 +2734,7 @@ TEST_F(AutocompleteResultTest, Desktop_TwoColumnRealbox) {
|
||||
{6, 1, 440, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group3},
|
||||
{7, 1, 430, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group3},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
|
||||
// Verify that the secondary zero-prefix suggestions were triggered.
|
||||
VerifyTriggeredFeatures(triggered_feature_service(),
|
||||
@ -2780,7 +2769,7 @@ TEST_F(AutocompleteResultTest, Desktop_TwoColumnRealbox) {
|
||||
{6, 1, 440, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group3},
|
||||
{7, 1, 430, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group3},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
|
||||
// Verify that the secondary zero-prefix suggestions were triggered.
|
||||
VerifyTriggeredFeatures(triggered_feature_service(),
|
||||
@ -2809,7 +2798,7 @@ TEST_F(AutocompleteResultTest, Desktop_TwoColumnRealbox) {
|
||||
{3, 1, 470, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
{4, 1, 460, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
|
||||
// Verify that the secondary zero-prefix suggestions were not triggered.
|
||||
VerifyTriggeredFeatures(triggered_feature_service(), {});
|
||||
@ -2953,7 +2942,7 @@ TEST_F(AutocompleteResultTest, Android_InspireMe) {
|
||||
{3, 1, 470, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
{4, 1, 460, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3291,13 +3280,13 @@ TEST_F(AutocompleteResultTest, IOS_InspireMe) {
|
||||
{1, 1, 490, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
{2, 1, 480, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
} else {
|
||||
const std::array<TestData, 2> expected_data{{
|
||||
{0, 1, 500, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
{1, 1, 490, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3324,7 +3313,7 @@ TEST_F(AutocompleteResultTest, IOS_InspireMe) {
|
||||
{1, 1, 490, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
{2, 1, 480, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
} else {
|
||||
const std::array<TestData, 4> expected_data{{
|
||||
{0, 1, 500, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
@ -3332,7 +3321,7 @@ TEST_F(AutocompleteResultTest, IOS_InspireMe) {
|
||||
{2, 1, 480, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
{3, 1, 470, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3359,7 +3348,7 @@ TEST_F(AutocompleteResultTest, IOS_InspireMe) {
|
||||
{1, 1, 490, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
{2, 1, 480, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
} else {
|
||||
const std::array<TestData, 5> expected_data{{
|
||||
{0, 1, 500, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group1},
|
||||
@ -3368,7 +3357,7 @@ TEST_F(AutocompleteResultTest, IOS_InspireMe) {
|
||||
{3, 1, 470, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
{4, 1, 460, false, {}, AutocompleteMatchType::SEARCH_SUGGEST, group2},
|
||||
}};
|
||||
AssertResultMatches(result, expected_data.begin(), expected_data.size());
|
||||
AssertResultMatches(result, expected_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ AutocompleteMatch::DocumentType GetIconForMIMEType(
|
||||
AutocompleteMatch::DocumentType::DRIVE_FOLDER},
|
||||
});
|
||||
|
||||
const auto* it = kIconMap.find(mimetype);
|
||||
const auto it = kIconMap.find(mimetype);
|
||||
return it != kIconMap.end() ? it->second
|
||||
: AutocompleteMatch::DocumentType::DRIVE_OTHER;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ const CSVPassword::Label* NameToLabel(base::StringPiece name) {
|
||||
std::string trimmed_name;
|
||||
// Trim leading/trailing whitespaces from |name|.
|
||||
base::TrimWhitespaceASCII(name, base::TRIM_ALL, &trimmed_name);
|
||||
auto* it = kLabelMap.find(base::ToLowerASCII(trimmed_name));
|
||||
auto it = kLabelMap.find(base::ToLowerASCII(trimmed_name));
|
||||
return it != kLabelMap.end() ? &it->second : nullptr;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ size_t GetNoteHeaderPriority(base::StringPiece name) {
|
||||
std::string trimmed_name;
|
||||
// Trim leading/trailing whitespaces from |name|.
|
||||
base::TrimWhitespaceASCII(name, base::TRIM_ALL, &trimmed_name);
|
||||
auto* it = kNoteLabelsPriority.find(base::ToLowerASCII(trimmed_name));
|
||||
auto it = kNoteLabelsPriority.find(base::ToLowerASCII(trimmed_name));
|
||||
DCHECK(it != kNoteLabelsPriority.end());
|
||||
return it->second;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ constexpr char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost";
|
||||
|
||||
std::string GenerateDeviceLocalAccountUserId(std::string_view account_id,
|
||||
DeviceLocalAccountType type) {
|
||||
const auto* it = kDomainPrefixMap.find(type);
|
||||
const auto it = kDomainPrefixMap.find(type);
|
||||
CHECK(it != kDomainPrefixMap.end());
|
||||
return gaia::CanonicalizeEmail(
|
||||
base::StrCat({base::HexEncode(account_id), "@", it->second,
|
||||
|
@ -120,7 +120,7 @@ const char* GetHistogramSuffix(const base::FilePath& path) {
|
||||
&spaceless_basename);
|
||||
static constexpr std::array<const char*, 3> kAllowList{
|
||||
"Secure_Preferences", "Preferences", "Local_State"};
|
||||
const char* const* it = base::ranges::find(kAllowList, spaceless_basename);
|
||||
auto it = base::ranges::find(kAllowList, spaceless_basename);
|
||||
return it != kAllowList.end() ? *it : "";
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ bool ShouldOfferLinkToText(const GURL& url) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* block_list_it = kBlocklist.find(domain);
|
||||
auto block_list_it = kBlocklist.find(domain);
|
||||
if (block_list_it != kBlocklist.end()) {
|
||||
if (re2::RE2::FullMatch(url.path(), block_list_it->second.data())) {
|
||||
return false;
|
||||
|
@ -337,7 +337,7 @@ constexpr auto kCommonSyncablePrefsAllowlist =
|
||||
std::optional<SyncablePrefMetadata>
|
||||
CommonSyncablePrefsDatabase::GetSyncablePrefMetadata(
|
||||
const std::string& pref_name) const {
|
||||
const auto* it = kCommonSyncablePrefsAllowlist.find(pref_name);
|
||||
const auto it = kCommonSyncablePrefsAllowlist.find(pref_name);
|
||||
if (it == kCommonSyncablePrefsAllowlist.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ class NGramExtractor {
|
||||
Iterator(const NGramExtractor& extractor,
|
||||
base::StringPiece::const_iterator head)
|
||||
: extractor_(extractor), head_(head), end_(extractor.string_.end()) {
|
||||
DCHECK_GE(head, extractor_->string_.begin());
|
||||
DCHECK_LE(head, end_);
|
||||
DCHECK(head >= extractor_->string_.begin());
|
||||
DCHECK(head <= end_);
|
||||
|
||||
CompleteNGramFrom(0);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ constexpr auto kPolicyMap =
|
||||
|
||||
std::string_view MultiUserSignInPolicyToPrefValue(
|
||||
MultiUserSignInPolicy policy) {
|
||||
auto* it = kPolicyMap.find(policy);
|
||||
auto it = kPolicyMap.find(policy);
|
||||
CHECK_NE(it, kPolicyMap.end());
|
||||
return it->second;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ int GetMessageIdForIconEnum(const std::string& icon_type) {
|
||||
{"ICON_SUN", IDS_AX_IMAGE_ANNOTATION_ICON_SUN},
|
||||
});
|
||||
|
||||
auto* iter = kIconTypeToMessageIdMap.find(icon_type);
|
||||
auto iter = kIconTypeToMessageIdMap.find(icon_type);
|
||||
if (iter == kIconTypeToMessageIdMap.end())
|
||||
return 0;
|
||||
|
||||
|
@ -646,7 +646,7 @@ GamepadIdList& GamepadIdList::Get() {
|
||||
|
||||
XInputType GamepadIdList::GetXInputType(uint16_t vendor_id,
|
||||
uint16_t product_id) const {
|
||||
const auto* find_it = kGamepadInfo.find({vendor_id, product_id});
|
||||
const auto find_it = kGamepadInfo.find({vendor_id, product_id});
|
||||
return find_it == kGamepadInfo.end() ? kXInputTypeNone : find_it->second;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ WebRequestEventRouter::EventTypes GetEventTypeFromEventName(
|
||||
return WebRequestEventRouter::kInvalidEvent;
|
||||
}
|
||||
|
||||
const auto* it = kRequestStageMap.find(event_name);
|
||||
const auto it = kRequestStageMap.find(event_name);
|
||||
return it == kRequestStageMap.end() ? WebRequestEventRouter::kInvalidEvent
|
||||
: it->second;
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ static_assert(ValidateHeaderEntries(kRequestHeaderEntries),
|
||||
void RecordRequestHeader(const std::string& header,
|
||||
void (*record_func)(RequestHeaderType)) {
|
||||
DCHECK(IsStringLowerCaseASCII(header));
|
||||
const auto* it = kRequestHeaderEntries.find(header);
|
||||
const auto it = kRequestHeaderEntries.find(header);
|
||||
record_func(it != kRequestHeaderEntries.end() ? it->second
|
||||
: RequestHeaderType::kOther);
|
||||
}
|
||||
@ -320,7 +320,7 @@ constexpr auto kResponseHeaderEntries =
|
||||
void RecordResponseHeader(std::string_view header,
|
||||
void (*record_func)(ResponseHeaderType)) {
|
||||
DCHECK(IsStringLowerCaseASCII(header));
|
||||
const auto* it = kResponseHeaderEntries.find(header);
|
||||
const auto it = kResponseHeaderEntries.find(header);
|
||||
record_func(it != kResponseHeaderEntries.end() ? it->second
|
||||
: ResponseHeaderType::kOther);
|
||||
}
|
||||
@ -347,7 +347,7 @@ std::string GetDNRNewRequestHeaderValue(net::HttpRequestHeaders* headers,
|
||||
bool has_header = headers->GetHeader(header_name, &existing_value);
|
||||
|
||||
if (has_header && operation == dnr_api::HeaderOperation::kAppend) {
|
||||
const auto* it = dnr::kDNRRequestHeaderAppendAllowList.find(header_name);
|
||||
const auto it = dnr::kDNRRequestHeaderAppendAllowList.find(header_name);
|
||||
DCHECK(it != dnr::kDNRRequestHeaderAppendAllowList.end());
|
||||
return base::StrCat({existing_value, it->second, header_value});
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ bool ConvertEventStatus(const base::Value* value,
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto* it = kEventStatuses.find(*status);
|
||||
const auto it = kEventStatuses.find(*status);
|
||||
if (it != kEventStatuses.end()) {
|
||||
*result = it->second;
|
||||
} else {
|
||||
@ -163,7 +163,7 @@ std::optional<CalendarEvent::ResponseStatus> CalculateSelfResponseStatus(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto* it = kAttendeesResponseStatuses.find(*responseStatus);
|
||||
const auto it = kAttendeesResponseStatuses.find(*responseStatus);
|
||||
if (it != kAttendeesResponseStatuses.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ VideoResolutionDesignation ResolutionNameFromSize(gfx::Size frame_size) {
|
||||
frame_size.set_width(frame_size.height());
|
||||
frame_size.set_width(tmp);
|
||||
}
|
||||
auto* it = kResolutions.find(frame_size);
|
||||
auto it = kResolutions.find(frame_size);
|
||||
return it != kResolutions.end() ? it->second
|
||||
: VideoResolutionDesignation::kUnknown;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ TagKind GetTagKind(TagName name) {
|
||||
|
||||
std::optional<TagName> ParseTagName(std::string_view name) {
|
||||
// Search for the tag name
|
||||
const auto* match = kTagNames.find(name);
|
||||
const auto match = kTagNames.find(name);
|
||||
if (match == kTagNames.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ class NetworkAwareHostResolverProc : public HostResolverProc {
|
||||
handles::NetworkHandle network) override {
|
||||
// Presume failure
|
||||
*os_error = 1;
|
||||
const auto* iter = kResults.find(network);
|
||||
const auto iter = kResults.find(network);
|
||||
if (iter == kResults.end())
|
||||
return ERR_NETWORK_CHANGED;
|
||||
|
||||
|
@ -100,7 +100,7 @@ std::optional<DnsQueryType> QueryTypeFromValue(const base::Value& value) {
|
||||
const std::string* query_type_string = value.GetIfString();
|
||||
if (!query_type_string)
|
||||
return std::nullopt;
|
||||
const auto* query_type_it =
|
||||
const auto query_type_it =
|
||||
base::ranges::find(kDnsQueryTypes, *query_type_string,
|
||||
&decltype(kDnsQueryTypes)::value_type::second);
|
||||
if (query_type_it == kDnsQueryTypes.end())
|
||||
@ -281,7 +281,7 @@ bool HostResolverInternalResult::ValidateValueBaseDict(
|
||||
const std::string* query_type_string = dict.FindString(kValueQueryTypeKey);
|
||||
if (!query_type_string)
|
||||
return false;
|
||||
const auto* query_type_it =
|
||||
const auto query_type_it =
|
||||
base::ranges::find(kDnsQueryTypes, *query_type_string,
|
||||
&decltype(kDnsQueryTypes)::value_type::second);
|
||||
if (query_type_it == kDnsQueryTypes.end())
|
||||
|
@ -97,7 +97,7 @@ FilterSourceStream::SourceType FilterSourceStream::ParseEncodingType(
|
||||
{kXGZip, TYPE_GZIP},
|
||||
{kZstd, TYPE_ZSTD},
|
||||
});
|
||||
auto* encoding_type = kEncodingMap.find(lower_encoding);
|
||||
auto encoding_type = kEncodingMap.find(lower_encoding);
|
||||
if (encoding_type == kEncodingMap.end()) {
|
||||
return TYPE_UNKNOWN;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ enum ExtensionIndex FileNameToExtensionIndex(const std::u16string& file_name) {
|
||||
const std::string& extension = extension_str_lower;
|
||||
#endif
|
||||
|
||||
auto* const* it = base::ranges::find(kFileExtensions, extension);
|
||||
auto const it = base::ranges::find(kFileExtensions, extension);
|
||||
if (it == kFileExtensions.end())
|
||||
return ExtensionIndex::kOtherExt;
|
||||
|
||||
|
@ -172,8 +172,7 @@ mojom::PressureState CpuProbeManager::CalculateState(
|
||||
? kStateRandomizedThresholds
|
||||
: kStateBaseThresholds;
|
||||
|
||||
auto* it =
|
||||
base::ranges::lower_bound(kStateThresholds, sample.cpu_utilization);
|
||||
auto it = base::ranges::lower_bound(kStateThresholds, sample.cpu_utilization);
|
||||
if (it == kStateThresholds.end()) {
|
||||
NOTREACHED_NORETURN() << "unexpected value: " << sample.cpu_utilization;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ std::optional<network::mojom::RequestDestination> RequestDestinationFromString(
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
auto* it = kRequestDestinationFromStringMap.find(dest_str);
|
||||
auto it = kRequestDestinationFromStringMap.find(dest_str);
|
||||
if (it == kRequestDestinationFromStringMap.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ constexpr auto kSharedStorageHeaderParamTypeMap =
|
||||
|
||||
std::optional<mojom::SharedStorageOperationType>
|
||||
StringToSharedStorageOperationType(std::string_view operation_str) {
|
||||
auto* operation_it =
|
||||
auto operation_it =
|
||||
kSharedStorageOperationTypeMap.find(base::ToLowerASCII(operation_str));
|
||||
if (operation_it == kSharedStorageOperationTypeMap.end()) {
|
||||
return std::nullopt;
|
||||
@ -44,7 +44,7 @@ StringToSharedStorageOperationType(std::string_view operation_str) {
|
||||
|
||||
std::optional<SharedStorageHeaderParamType>
|
||||
StringToSharedStorageHeaderParamType(std::string_view param_str) {
|
||||
auto* param_it =
|
||||
auto param_it =
|
||||
kSharedStorageHeaderParamTypeMap.find(base::ToLowerASCII(param_str));
|
||||
if (param_it == kSharedStorageHeaderParamTypeMap.end()) {
|
||||
return std::nullopt;
|
||||
|
@ -147,7 +147,7 @@ std::string GetMainContentExtractorRoleFromChromeRole(ax::mojom::Role role) {
|
||||
{ax::mojom::Role::kComboBoxMenuButton, "combobox"},
|
||||
{ax::mojom::Role::kTextFieldWithComboBox, "combobox"}});
|
||||
|
||||
const auto* it = kRolesWithDifferentName.find(role);
|
||||
const auto it = kRolesWithDifferentName.find(role);
|
||||
if (it != kRolesWithDifferentName.end()) {
|
||||
return std::string(it->second);
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ bool ValidateElementWiseUnary(const IdToOperandMap& id_to_operand_map,
|
||||
if (operation->kind == mojom::ElementWiseUnary::Kind::kCast) {
|
||||
return ValidateCastOperation(id_to_operand_map, operation);
|
||||
}
|
||||
const auto* constraints_iterator =
|
||||
const auto constraints_iterator =
|
||||
kUnaryOperatorConstraints.find(operation->kind);
|
||||
CHECK_NE(constraints_iterator, kUnaryOperatorConstraints.end());
|
||||
return ValidateUnaryOperation(id_to_operand_map, operation,
|
||||
|
@ -39,7 +39,7 @@ std::string ToString(const AXPositionKind kind) {
|
||||
{AXPositionKind::TREE_POSITION, "TreePosition"},
|
||||
{AXPositionKind::TEXT_POSITION, "TextPosition"}});
|
||||
|
||||
const auto* iter = kKindToString.find(kind);
|
||||
const auto iter = kKindToString.find(kind);
|
||||
if (iter == std::end(kKindToString))
|
||||
return std::string();
|
||||
return iter->second;
|
||||
|
@ -81,7 +81,7 @@ std::optional<EndpointType> EndpointStringToType(
|
||||
{kClipboardHistoryString, EndpointType::kClipboardHistory},
|
||||
});
|
||||
|
||||
auto* it = kEndpointStringToTypeMap.find(endpoint_string);
|
||||
auto it = kEndpointStringToTypeMap.find(endpoint_string);
|
||||
if (it != kEndpointStringToTypeMap.end())
|
||||
return it->second;
|
||||
|
||||
|
@ -160,7 +160,7 @@ struct EnumStringsMap;
|
||||
std::u16string ui::metadata::TypeConverter<T>::ToString( \
|
||||
ui::metadata::ArgType<T> source_value) { \
|
||||
const auto& map = EnumStringsMap<T>::Get(); \
|
||||
auto* it = map.find(source_value); \
|
||||
auto it = map.find(source_value); \
|
||||
return it != map.end() ? std::u16string(it->second) : std::u16string(); \
|
||||
} \
|
||||
\
|
||||
@ -169,7 +169,7 @@ struct EnumStringsMap;
|
||||
const std::u16string& str) { \
|
||||
const auto& map = EnumStringsMap<T>::Get(); \
|
||||
using Pair = base::ranges::range_value_t<decltype(map)>; \
|
||||
auto* it = base::ranges::find(map, str, &Pair::second); \
|
||||
auto it = base::ranges::find(map, str, &Pair::second); \
|
||||
return it != map.end() ? std::make_optional(it->first) : std::nullopt; \
|
||||
} \
|
||||
\
|
||||
|
@ -205,7 +205,7 @@ base::StringPiece SystemThemeName(ui::SystemTheme system_theme) {
|
||||
std::string ColorIdName(ColorId color_id) {
|
||||
static constexpr const auto color_id_map =
|
||||
base::MakeFixedFlatMap<ColorId, const char*>({COLOR_IDS});
|
||||
auto* i = color_id_map.find(color_id);
|
||||
auto i = color_id_map.find(color_id);
|
||||
if (i != color_id_map.cend())
|
||||
return {i->second};
|
||||
base::StringPiece color_name;
|
||||
@ -328,7 +328,7 @@ std::string SkColorName(SkColor color) {
|
||||
auto color_with_alpha = color;
|
||||
SkAlpha color_alpha = SkColorGetA(color_with_alpha);
|
||||
color = SkColorSetA(color, color_alpha != 0 ? SK_AlphaOPAQUE : color_alpha);
|
||||
auto* i = color_name_map.find(color);
|
||||
auto i = color_name_map.find(color);
|
||||
if (i != color_name_map.cend()) {
|
||||
if (SkColorGetA(color_with_alpha) == SkColorGetA(color))
|
||||
return i->second;
|
||||
|
@ -50,7 +50,7 @@ template <typename M, typename K>
|
||||
const char* GetMapValueOrDefault(const M& map,
|
||||
const K& key,
|
||||
const char* default_value = "unknown") {
|
||||
auto* pair = map.find(key);
|
||||
auto pair = map.find(key);
|
||||
return pair == map.end() ? default_value : pair->second;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,12 @@ void CreateColorSpaceFromNames(wl_client* client,
|
||||
GetUserDataAs<TestZcrColorSpaceV1>(color_space_resource);
|
||||
|
||||
auto chromaticity_id = gfx::ColorSpace::PrimaryID::INVALID;
|
||||
const auto* maybe_primary = ui::wayland::kChromaticityMap.find(chromaticity);
|
||||
const auto maybe_primary = ui::wayland::kChromaticityMap.find(chromaticity);
|
||||
if (maybe_primary != ui::wayland::kChromaticityMap.end()) {
|
||||
chromaticity_id = maybe_primary->second.primary;
|
||||
}
|
||||
auto eotf_id = gfx::ColorSpace::TransferID::INVALID;
|
||||
const auto* maybe_eotf = ui::wayland::kEotfMap.find(eotf);
|
||||
const auto maybe_eotf = ui::wayland::kEotfMap.find(eotf);
|
||||
if (maybe_eotf != ui::wayland::kEotfMap.end()) {
|
||||
eotf_id = maybe_eotf->second.transfer;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ ShapeSysTokens GetShapeSysToken(ShapeContextTokens id) {
|
||||
{ShapeContextTokens::kSidePanelPageContentRadius,
|
||||
ShapeSysTokens::kSmall},
|
||||
});
|
||||
const auto* it = shape_token_map.find(id);
|
||||
const auto it = shape_token_map.find(id);
|
||||
return it == shape_token_map.end() ? ShapeSysTokens::kDefault : it->second;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ int TypographyProvider::GetLineHeightImpl(int context, int style) const {
|
||||
{style::STYLE_BODY_5_MEDIUM, 16}, {style::STYLE_BODY_5_BOLD, 16},
|
||||
{style::STYLE_CAPTION, 12},
|
||||
});
|
||||
const auto* const it = kLineHeights.find(style);
|
||||
const auto it = kLineHeights.find(style);
|
||||
return (it == kLineHeights.end())
|
||||
? GetFontForDetails(GetFontDetailsImpl(context, style)).GetHeight()
|
||||
: it->second;
|
||||
|
Reference in New Issue
Block a user