libcamera: device_enumerator: Remove move() on search() return

Remove the std::move() call on the shared_ptr<MediaDevice *> returned by
the search() method and remove the std::move() call on temporary return
value in pipeline handlers that use the method.

Thanks to copy elision, the regular constructor of the newly created
object is called, avoiding un-necessary copies.

Furthermore, the use of std::move() in the return and assignment
statements prevents the compiler from performing copy elision, forcing
it to generate two sequences of un-necessary calls to the class'
move constructor and destructor.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi
2019-02-12 21:48:10 +01:00
parent fea6dc9365
commit ddcd8ebb3d
4 changed files with 5 additions and 5 deletions

View File

@@ -308,7 +308,7 @@ std::shared_ptr<MediaDevice> DeviceEnumerator::search(const DeviceMatch &dm)
LOG(DeviceEnumerator, Debug)
<< "Successful match for media device \""
<< media->driver() << "\"";
return std::move(media);
return media;
}
}