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...
This commit is contained in:
Fischlurch 2017-08-12 16:27:30 +02:00
parent b9acb3f50f
commit 32f2d6ed9a

View file

@ -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};
}