libcamera: Use const reference for range loops
Use a const reference in range-based for loops to avoid copies of the loop elements. While at it, change looping over controls in PipelineHandlerUVC::processControls to use structured bindings. Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
committed by
Jacopo Mondi
parent
868ab2287d
commit
45c198da63
@@ -189,7 +189,7 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera,
|
||||
{
|
||||
MutexLocker locker(mutex_);
|
||||
|
||||
for (std::shared_ptr<Camera> c : cameras_) {
|
||||
for (const std::shared_ptr<Camera> &c : cameras_) {
|
||||
if (c->id() == camera->id()) {
|
||||
LOG(Camera, Fatal)
|
||||
<< "Trying to register a camera with a duplicated ID '"
|
||||
|
||||
@@ -161,7 +161,7 @@ std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()
|
||||
|
||||
DeviceEnumerator::~DeviceEnumerator()
|
||||
{
|
||||
for (std::shared_ptr<MediaDevice> media : devices_) {
|
||||
for (const std::shared_ptr<MediaDevice> &media : devices_) {
|
||||
if (media->busy())
|
||||
LOG(DeviceEnumerator, Error)
|
||||
<< "Removing media device " << media->deviceNode()
|
||||
|
||||
@@ -340,12 +340,8 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)
|
||||
{
|
||||
ControlList controls(data->video_->controls());
|
||||
|
||||
for (auto it : request->controls()) {
|
||||
unsigned int id = it.first;
|
||||
ControlValue &value = it.second;
|
||||
|
||||
for (const auto &[id, value] : request->controls())
|
||||
processControl(&controls, id, value);
|
||||
}
|
||||
|
||||
for (const auto &ctrl : controls)
|
||||
LOG(UVC, Debug)
|
||||
|
||||
@@ -378,7 +378,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
|
||||
{
|
||||
ControlList controls(data->sensor_->controls());
|
||||
|
||||
for (auto it : request->controls()) {
|
||||
for (const auto &it : request->controls()) {
|
||||
unsigned int id = it.first;
|
||||
unsigned int offset;
|
||||
uint32_t cid;
|
||||
|
||||
@@ -616,7 +616,7 @@ void PipelineHandler::disconnect()
|
||||
*/
|
||||
std::vector<std::weak_ptr<Camera>> cameras{ std::move(cameras_) };
|
||||
|
||||
for (std::weak_ptr<Camera> ptr : cameras) {
|
||||
for (const std::weak_ptr<Camera> &ptr : cameras) {
|
||||
std::shared_ptr<Camera> camera = ptr.lock();
|
||||
if (!camera)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user