db: schema_tables: unpeel lw_shared_ptr in create_Tables_from_tables_partition()

The tables local is a lw_shared_ptr which is created and then refeferenced
before returning. It can be unpeeled to the pointed-to type, resulting in
one less allocation.
This commit is contained in:
Avi Kivity
2021-08-01 16:57:59 +03:00
parent 66054d24c4
commit 0843d441ff

View File

@@ -2347,15 +2347,15 @@ future<schema_ptr> create_table_from_name(distributed<service::storage_proxy>& p
*/
future<std::map<sstring, schema_ptr>> create_tables_from_tables_partition(distributed<service::storage_proxy>& proxy, const schema_result::mapped_type& result)
{
auto tables = make_lw_shared<std::map<sstring, schema_ptr>>();
auto tables = std::map<sstring, schema_ptr>();
co_await parallel_for_each(result->rows().begin(), result->rows().end(), [&] (const query::result_set_row& row) -> future<> {
schema_ptr cfm = co_await create_table_from_table_row(proxy, row);
{
tables->emplace(cfm->cf_name(), std::move(cfm));
tables.emplace(cfm->cf_name(), std::move(cfm));
}
});
{
co_return std::move(*tables);
co_return std::move(tables);
}
}