diff --git a/collection_mutation.cc b/collection_mutation.cc index 1ac64639bb..bc0eb0ad9f 100644 --- a/collection_mutation.cc +++ b/collection_mutation.cc @@ -33,7 +33,7 @@ collection_mutation::collection_mutation(const abstract_type& type, collection_m : _data(imr_object_type::make(data::cell::make_collection(v.data), &type.imr_state().lsa_migrator())) {} collection_mutation::collection_mutation(const abstract_type& type, const bytes_ostream& data) - : _data(imr_object_type::make(data::cell::make_collection(data), &type.imr_state().lsa_migrator())) {} + : _data(imr_object_type::make(data::cell::make_collection(fragment_range_view(data)), &type.imr_state().lsa_migrator())) {} static collection_mutation_view get_collection_mutation_view(const uint8_t* ptr) { diff --git a/data/cell.hh b/data/cell.hh index cd97b501d7..1da72b0964 100644 --- a/data/cell.hh +++ b/data/cell.hh @@ -277,23 +277,6 @@ private: static thread_local imr::alloc::lsa_migrate_fn> lsa_chunk_migrate_fn; - template - GCC6_CONCEPT( - requires std::is_nothrow_move_constructible_v> && - std::is_nothrow_copy_constructible_v> && - std::is_nothrow_copy_assignable_v> && - std::is_nothrow_move_assignable_v> - ) - static auto do_make_collection(FragmentRangeView&& data) noexcept { - return [data] (auto&& serializer, auto&& allocations) noexcept { - return serializer - .serialize(imr::set_flag(), - imr::set_flag(data.size_bytes() > maximum_internal_storage_length)) - .template serialize_as(variable_value::write(data), allocations) - .done(); - }; - } - public: /// Make a writer that copies a cell /// @@ -309,25 +292,24 @@ public: /// \arg data needs to remain valid as long as the writer is in use. /// \returns imr::WriterAllocator for cell::structure. template>>> - static auto make_collection(const FragmentRange& data) noexcept { - // The writer (`do_make_collection()`) is noexcept so we have to make - // sure the data can be copied/moved without the risk of throwing - // exceptions. If `data` is nothrow copyable already, which is the - // case when `data` is a view, we forward it as-is. Otherwise we - // wrap `data` in a view and forward the view. We require the caller - // to keep `data` alive anyway. - if constexpr (std::is_nothrow_move_constructible_v> && + GCC6_CONCEPT( + requires std::is_nothrow_move_constructible_v> && std::is_nothrow_copy_constructible_v> && std::is_nothrow_copy_assignable_v> && - std::is_nothrow_move_assignable_v>) { - return do_make_collection(data); - } else { - return do_make_collection(fragment_range_view(data)); - } + std::is_nothrow_move_assignable_v> + ) + static auto make_collection(FragmentRange data) noexcept { + return [data = std::move(data)] (auto&& serializer, auto&& allocations) noexcept { + return serializer + .serialize(imr::set_flag(), + imr::set_flag(data.size_bytes() > maximum_internal_storage_length)) + .template serialize_as(variable_value::write(data), allocations) + .done(); + }; } static auto make_collection(bytes_view data) noexcept { - return do_make_collection(single_fragment_range(data)); + return make_collection(single_fragment_range(data)); } /// Make a writer for a dead cell