This is an automated email from the ASF dual-hosted git repository.
gangwu 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 02f03354 refactor: Reduce extra lookup in RegisterTable (#549)
02f03354 is described below
commit 02f03354189d5e39c64d3a9d95f30c49a515e864
Author: Maxim Zibitsker <[email protected]>
AuthorDate: Fri Jan 30 21:00:46 2026 -0500
refactor: Reduce extra lookup in RegisterTable (#549)
---
src/iceberg/catalog/memory/in_memory_catalog.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/iceberg/catalog/memory/in_memory_catalog.cc
b/src/iceberg/catalog/memory/in_memory_catalog.cc
index 25b0064c..8a082aad 100644
--- a/src/iceberg/catalog/memory/in_memory_catalog.cc
+++ b/src/iceberg/catalog/memory/in_memory_catalog.cc
@@ -295,10 +295,13 @@ Status InMemoryNamespace::RegisterTable(const
TableIdentifier& table_ident,
const std::string& metadata_location) {
const auto ns = GetNamespace(this, table_ident.ns);
ICEBERG_RETURN_UNEXPECTED(ns);
- if (ns.value()->table_metadata_locations_.contains(table_ident.name)) {
+ const auto inserted =
+ ns.value()
+ ->table_metadata_locations_.try_emplace(table_ident.name,
metadata_location)
+ .second;
+ if (!inserted) {
return AlreadyExists("{} already exists", table_ident.name);
}
- ns.value()->table_metadata_locations_[table_ident.name] = metadata_location;
return {};
}