Message ID | 20250331150611.523218-1-barnabas.pocze@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On Mon, Mar 31, 2025 at 05:06:11PM +0200, Barnabás Pőcze wrote: > `std::find()` works just fine because `std::shared_ptr` has > `operator==()` with the expected semantics. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/camera_manager.cpp | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp > index 400109f12..b28bd0bd2 100644 > --- a/src/libcamera/camera_manager.cpp > +++ b/src/libcamera/camera_manager.cpp > @@ -239,10 +239,7 @@ void CameraManager::Private::removeCamera(std::shared_ptr<Camera> camera) > { > MutexLocker locker(mutex_); > > - auto iter = std::find_if(cameras_.begin(), cameras_.end(), > - [camera](std::shared_ptr<Camera> &c) { > - return c.get() == camera.get(); > - }); > + auto iter = std::find(cameras_.begin(), cameras_.end(), camera); > if (iter == cameras_.end()) > return; >
Quoting Barnabás Pőcze (2025-03-31 16:06:11) > `std::find()` works just fine because `std::shared_ptr` has > `operator==()` with the expected semantics. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/camera_manager.cpp | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp > index 400109f12..b28bd0bd2 100644 > --- a/src/libcamera/camera_manager.cpp > +++ b/src/libcamera/camera_manager.cpp > @@ -239,10 +239,7 @@ void CameraManager::Private::removeCamera(std::shared_ptr<Camera> camera) > { > MutexLocker locker(mutex_); > > - auto iter = std::find_if(cameras_.begin(), cameras_.end(), > - [camera](std::shared_ptr<Camera> &c) { > - return c.get() == camera.get(); > - }); > + auto iter = std::find(cameras_.begin(), cameras_.end(), camera); > if (iter == cameras_.end()) > return; > > -- > 2.49.0 >
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 400109f12..b28bd0bd2 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -239,10 +239,7 @@ void CameraManager::Private::removeCamera(std::shared_ptr<Camera> camera) { MutexLocker locker(mutex_); - auto iter = std::find_if(cameras_.begin(), cameras_.end(), - [camera](std::shared_ptr<Camera> &c) { - return c.get() == camera.get(); - }); + auto iter = std::find(cameras_.begin(), cameras_.end(), camera); if (iter == cameras_.end()) return;
`std::find()` works just fine because `std::shared_ptr` has `operator==()` with the expected semantics. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/libcamera/camera_manager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)