apps: lc-compliance: Optimize std::shared_ptr
usage
Avoid unnecessary copies and try to move construct `std::shared_ptr` whenever possible. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
6719ae34cc
commit
d338fe9336
2 changed files with 5 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue