@@ -12,8 +12,8 @@
using namespace libcamera;
Capture::Capture(std::shared_ptr<Camera> camera)
- : loop_(nullptr), camera_(camera),
- allocator_(std::make_unique<FrameBufferAllocator>(camera))
+ : loop_(nullptr), camera_(std::move(camera)),
+ allocator_(std::make_unique<FrameBufferAllocator>(camera_))
{
}
@@ -72,7 +72,7 @@ void Capture::stop()
/* CaptureBalanced */
CaptureBalanced::CaptureBalanced(std::shared_ptr<Camera> camera)
- : Capture(camera)
+ : Capture(std::move(camera))
{
}
@@ -144,7 +144,7 @@ void CaptureBalanced::requestComplete(Request *request)
/* CaptureUnbalanced */
CaptureUnbalanced::CaptureUnbalanced(std::shared_ptr<Camera> camera)
- : Capture(camera)
+ : Capture(std::move(camera))
{
}
@@ -50,8 +50,6 @@ static void listCameras(CameraManager *cm)
static int initCamera(CameraManager *cm, OptionsParser::Options options)
{
- std::shared_ptr<Camera> camera;
-
int ret = cm->start();
if (ret) {
std::cout << "Failed to start camera manager: "
@@ -66,7 +64,7 @@ static int initCamera(CameraManager *cm, OptionsParser::Options options)
}
const std::string &cameraId = options[OptCamera];
- camera = cm->get(cameraId);
+ std::shared_ptr<Camera> camera = cm->get(cameraId);
if (!camera) {
std::cout << "Camera " << cameraId << " not found, available cameras:" << std::endl;
listCameras(cm);
Avoid unnecessary copies and try to move construct `std::shared_ptr` whenever possible. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> --- src/apps/lc-compliance/helpers/capture.cpp | 8 ++++---- src/apps/lc-compliance/main.cpp | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-)