Skip to content

Commit 0e59e2a

Browse files
authored
Reduce extra lookup in RegisterTable
1 parent 5dda5a3 commit 0e59e2a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/iceberg/catalog/memory/in_memory_catalog.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,12 @@ 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+
auto const inserted =
299+
ns.value()->table_metadata_locations_.
300+
try_emplace(table_ident.name, metadata_location).second;
301+
if (!inserted) {
299302
return AlreadyExists("{} already exists", table_ident.name);
300303
}
301-
ns.value()->table_metadata_locations_[table_ident.name] = metadata_location;
302304
return {};
303305
}
304306

0 commit comments

Comments
 (0)