diff --git a/include/bitcoin/database/impl/primitives/hashmap.ipp b/include/bitcoin/database/impl/primitives/hashmap.ipp index 48d35154..72674df7 100644 --- a/include/bitcoin/database/impl/primitives/hashmap.ipp +++ b/include/bitcoin/database/impl/primitives/hashmap.ipp @@ -273,24 +273,15 @@ bool CLASS::put_link(Link& link, const Key& key, if (!ptr) return false; + // iostream.flush is a nop (direct copy). iostream stream{ *ptr }; finalizer sink{ stream }; sink.skip_bytes(Link::size); sink.write_bytes(key); - // The finalizer provides deferred index commit following serialization. - // Because the lambda captures ptr and is in turn held as a member of sink, - // ptr is guaranteed in scope until sink destruction, which follows flush. - // It may be possible to instead assign ptr to a sink member, but not being - // referenced would make it subject to optimization (volatile might work). - sink.set_finalizer([this, link, index = head_.index(key), ptr]() NOEXCEPT - { - auto& next = unsafe_array_cast(ptr->begin()); - return head_.push(link, next, index); - }); - if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) } - return element.to_data(sink) && sink.finalize(); + auto& next = unsafe_array_cast(ptr->begin()); + return element.to_data(sink) && head_.push(link, next, head_.index(key)); } TEMPLATE @@ -311,24 +302,15 @@ bool CLASS::put(const Link& link, const Key& key, if (!ptr) return false; + // iostream.flush is a nop (direct copy). iostream stream{ *ptr }; finalizer sink{ stream }; sink.skip_bytes(Link::size); sink.write_bytes(key); - // The finalizer provides deferred index commit following serialization. - // Because the lambda captures ptr and is in turn held as a member of sink, - // ptr is guaranteed in scope until sink destruction, which follows flush. - // It may be possible to instead assign ptr to a sink member, but not being - // referenced would make it subject to optimization (volatile might work). - sink.set_finalizer([this, link, index = head_.index(key), ptr]() NOEXCEPT - { - auto& next = unsafe_array_cast(ptr->begin()); - return head_.push(link, next, index); - }); - if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) } - return element.to_data(sink) && sink.finalize(); + auto& next = unsafe_array_cast(ptr->begin()); + return element.to_data(sink) && head_.push(link, next, head_.index(key)); } TEMPLATE