This is an automated email from the ASF dual-hosted git repository.
wgtmac pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 9d42a74d refactor: use contains for membership checks (#1086)
9d42a74d is described below
commit 9d42a74def0be91d35b2a3f8402c9f86290f972c
Author: Sreesh Maheshwar <[email protected]>
AuthorDate: Thu Nov 5 06:51:40 2026 +0000
refactor: use contains for membership checks (#1086)
---
src/iceberg/metadata_columns.cc | 5 ++---
src/iceberg/table_metadata.cc | 2 +-
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/metadata_columns.cc b/src/iceberg/metadata_columns.cc
index e00bc166..c4119156 100644
--- a/src/iceberg/metadata_columns.cc
+++ b/src/iceberg/metadata_columns.cc
@@ -58,12 +58,11 @@ const std::set<int32_t>&
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);
}
bool MetadataColumns::IsRowLineageColumn(int32_t id) {
diff --git a/src/iceberg/table_metadata.cc b/src/iceberg/table_metadata.cc
index b67ab32f..b41b2abb 100644
--- a/src/iceberg/table_metadata.cc
+++ b/src/iceberg/table_metadata.cc
@@ -800,7 +800,7 @@ Status
TableMetadataBuilder::Impl::SetDefaultSortOrder(int32_t order_id) {
Result<int32_t> TableMetadataBuilder::Impl::AddSortOrder(const SortOrder&
order) {
int32_t new_order_id = ReuseOrCreateNewSortOrderId(order);
- if (sort_orders_by_id_.find(new_order_id) != sort_orders_by_id_.end()) {
+ if (sort_orders_by_id_.contains(new_order_id)) {
// update last_added_order_id if the order was added in this set of
changes (since it
// is now the last)
bool is_new_order =
diff --git a/src/iceberg/util/content_file_util.cc
b/src/iceberg/util/content_file_util.cc
index 23eeaec8..fb6cc555 100644
--- a/src/iceberg/util/content_file_util.cc
+++ b/src/iceberg/util/content_file_util.cc
@@ -105,7 +105,7 @@ template <typename V>
void DropUnselectedColumnStats(std::map<int32_t, V>& map,
const std::unordered_set<int32_t>& 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 fe622c8e..eccf80de 100644
--- a/src/iceberg/util/struct_like_set.cc
+++ b/src/iceberg/util/struct_like_set.cc
@@ -584,7 +584,7 @@ Result<bool> StructLikeSet<kValidate>::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 <bool kValidate>