From 4505d973bedb5e51345e3b1c0882ba5a1ffa8e44 Mon Sep 17 00:00:00 2001 From: Sreesh Maheshwar Date: Sun, 28 Jun 2026 00:17:11 +0100 Subject: [PATCH] refactor: use contains() for associative-container membership checks Replace `find(x) != end()` / `find(x) == end()` membership tests with the C++20 `contains()` member, matching the codebase's prevailing idiom. In metadata_columns.cc this also avoids invoking the accessor twice per call. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/iceberg/catalog/rest/auth/auth_properties.cc | 2 +- src/iceberg/metadata_columns.cc | 5 ++--- src/iceberg/util/content_file_util.cc | 2 +- src/iceberg/util/struct_like_set.cc | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/iceberg/catalog/rest/auth/auth_properties.cc b/src/iceberg/catalog/rest/auth/auth_properties.cc index dcf16782c..45393aa45 100644 --- a/src/iceberg/catalog/rest/auth/auth_properties.cc +++ b/src/iceberg/catalog/rest/auth/auth_properties.cc @@ -62,7 +62,7 @@ Result AuthProperties::FromProperties( } // Resolve token endpoint: if not explicitly set, derive from catalog URI - if (properties.find(kOAuth2ServerUri.key()) == properties.end() || + if (!properties.contains(kOAuth2ServerUri.key()) || properties.at(kOAuth2ServerUri.key()).empty()) { auto uri_it = properties.find(RestCatalogProperties::kUri.key()); if (uri_it != properties.end() && !uri_it->second.empty()) { diff --git a/src/iceberg/metadata_columns.cc b/src/iceberg/metadata_columns.cc index 0c2521133..d12c9906e 100644 --- a/src/iceberg/metadata_columns.cc +++ b/src/iceberg/metadata_columns.cc @@ -58,12 +58,11 @@ const std::set& MetadataColumns::MetadataFieldIds() { } bool MetadataColumns::IsMetadataColumn(std::string_view name) { - return name == kPartitionColumnName || - GetMetadataColumnMap().find(name) != GetMetadataColumnMap().end(); + return name == kPartitionColumnName || GetMetadataColumnMap().contains(name); } bool MetadataColumns::IsMetadataColumn(int32_t id) { - return GetMetadataFieldIdSet().find(id) != GetMetadataFieldIdSet().end(); + return GetMetadataFieldIdSet().contains(id); } Result MetadataColumns::MetadataColumn(std::string_view name) { diff --git a/src/iceberg/util/content_file_util.cc b/src/iceberg/util/content_file_util.cc index 89c875087..7ae280667 100644 --- a/src/iceberg/util/content_file_util.cc +++ b/src/iceberg/util/content_file_util.cc @@ -98,7 +98,7 @@ template void DropUnselectedColumnStats(std::map& map, const std::unordered_set& columns) { for (auto it = map.begin(); it != map.end();) { - if (columns.find(it->first) == columns.end()) { + if (!columns.contains(it->first)) { it = map.erase(it); } else { ++it; diff --git a/src/iceberg/util/struct_like_set.cc b/src/iceberg/util/struct_like_set.cc index 35a0f9e28..64bf4f777 100644 --- a/src/iceberg/util/struct_like_set.cc +++ b/src/iceberg/util/struct_like_set.cc @@ -580,7 +580,7 @@ Result StructLikeSet::Contains(const StructLike& row) const { if constexpr (kValidate) { ICEBERG_RETURN_UNEXPECTED(ValidateRowAgainstTypes(row, field_types_)); } - return set_.find(row) != set_.end(); + return set_.contains(row); } template