Skip to content

Commit aac23b4

Browse files
committed
refactor: use std::make_shared instead of raw new in RestCatalog
Replace raw new with std::make_shared for better exception safety and modern C++ best practices in RestCatalog::Make(). Using std::make_shared provides: - Better exception safety (no leak if constructor throws) - More efficient memory allocation (single allocation for control block and object) - More concise and readable code - Consistent with modern C++ guidelines
1 parent 7e784dc commit aac23b4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
107107
ICEBERG_ASSIGN_OR_RAISE(auto final_uri, final_config->Uri());
108108
ICEBERG_RETURN_UNEXPECTED(paths->SetBaseUri(std::string(TrimTrailingSlash(final_uri))));
109109

110-
return std::shared_ptr<RestCatalog>(
111-
new RestCatalog(std::move(final_config), std::move(file_io), std::move(paths),
112-
std::move(endpoints)));
110+
return std::make_shared<RestCatalog>(std::move(final_config), std::move(file_io),
111+
std::move(paths), std::move(endpoints));
113112
}
114113

115114
RestCatalog::RestCatalog(std::unique_ptr<RestCatalogProperties> config,

0 commit comments

Comments
 (0)