From 32f2d6ed9a4d3c2802dafd6fcf62dfaabf97456a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 12 Aug 2017 16:27:30 +0200 Subject: [PATCH] IterSource: optimise hand-over at construction by moving, we can avoid the generation of up to 3 additional shared copies of the DataHandle. The whole invocation now works without touching any shared count and thus without incurring a memory barrier... --- src/lib/iter-source.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/iter-source.hpp b/src/lib/iter-source.hpp index bacc0835e..28d02d29e 100644 --- a/src/lib/iter-source.hpp +++ b/src/lib/iter-source.hpp @@ -155,8 +155,8 @@ namespace lib { static iterator build (IterSource& sourceImpl) { - DataHandle sourceHandle (&sourceImpl, &detach_without_destroy); - return startIteration(sourceHandle); + return std::move( + startIteration (DataHandle{&sourceImpl, &detach_without_destroy})); } /** build an iterator frontend, thereby managing @@ -168,8 +168,8 @@ namespace lib { static iterator build (IterSource* sourceImplObject) { - DataHandle sourceHandle (sourceImplObject, &destroy_managed_source); - return startIteration(sourceHandle); + return std::move( + startIteration (DataHandle{sourceImplObject, &destroy_managed_source})); } static iterator EMPTY_SOURCE; @@ -182,7 +182,7 @@ namespace lib { { REQUIRE (sourceHandle); Pos first = sourceHandle->firstResult(); - return iterator (sourceHandle, first); + return {move(sourceHandle), first}; }