Skip to content

Commit 02f0335

Browse files
authored
refactor: Reduce extra lookup in RegisterTable (#549)
1 parent 5dda5a3 commit 02f0335

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/iceberg/catalog/memory/in_memory_catalog.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,13 @@ Status InMemoryNamespace::RegisterTable(const TableIdentifier& table_ident,
295295
const std::string& metadata_location) {
296296
const auto ns = GetNamespace(this, table_ident.ns);
297297
ICEBERG_RETURN_UNEXPECTED(ns);
298-
if (ns.value()->table_metadata_locations_.contains(table_ident.name)) {
298+
const auto inserted =
299+
ns.value()
300+
->table_metadata_locations_.try_emplace(table_ident.name, metadata_location)
301+
.second;
302+
if (!inserted) {
299303
return AlreadyExists("{} already exists", table_ident.name);
300304
}
301-
ns.value()->table_metadata_locations_[table_ident.name] = metadata_location;
302305
return {};
303306
}
304307

0 commit comments

Comments
 (0)