| Message ID | 20260212123555.2686756-1-laurent.pinchart@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Laurent Pinchart (2026-02-12 12:35:55) > Use structured bindings when iterating over a map in range-based for > loops. This improves readability. I think you know my dislike for .first/.second readability so this is a very easy: Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/pipeline/ipu3/ipu3.cpp | 11 +++-------- > src/libcamera/pipeline/vimc/vimc.cpp | 3 +-- > src/libcamera/v4l2_videodevice.cpp | 6 ++---- > 3 files changed, 6 insertions(+), 14 deletions(-) > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp > index 0190f677e679..d1d4d85ebe76 100644 > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp > @@ -791,8 +791,7 @@ void IPU3CameraData::cancelPendingRequests() > while (!pendingRequests_.empty()) { > Request *request = pendingRequests_.front(); > > - for (auto it : request->buffers()) { > - FrameBuffer *buffer = it.second; > + for (auto [stream, buffer] : request->buffers()) { > buffer->_d()->cancel(); > pipe()->completeBuffer(request, buffer); > } > @@ -1225,10 +1224,7 @@ void IPU3CameraData::paramsComputed(unsigned int id) > return; > > /* Queue all buffers from the request aimed for the ImgU. */ > - for (auto it : info->request->buffers()) { > - const Stream *stream = it.first; > - FrameBuffer *outbuffer = it.second; > - > + for (auto [stream, outbuffer] : info->request->buffers()) { > if (stream == &outStream_) > imgu_->output_->queueBuffer(outbuffer); > else if (stream == &vfStream_) > @@ -1304,8 +1300,7 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) > > /* If the buffer is cancelled force a complete of the whole request. */ > if (buffer->metadata().status == FrameMetadata::FrameCancelled) { > - for (auto it : request->buffers()) { > - FrameBuffer *b = it.second; > + for (auto [stream, b] : request->buffers()) { > b->_d()->cancel(); > pipe()->completeBuffer(request, b); > } > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp > index 4a03c149a617..025e7dbdd26f 100644 > --- a/src/libcamera/pipeline/vimc/vimc.cpp > +++ b/src/libcamera/pipeline/vimc/vimc.cpp > @@ -607,8 +607,7 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) > > /* If the buffer is cancelled force a complete of the whole request. */ > if (buffer->metadata().status == FrameMetadata::FrameCancelled) { > - for (auto it : request->buffers()) { > - FrameBuffer *b = it.second; > + for (auto [stream, b] : request->buffers()) { > b->_d()->cancel(); > pipe->completeBuffer(request, b); > } > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp > index 25b61d049a0e..02c50886a084 100644 > --- a/src/libcamera/v4l2_videodevice.cpp > +++ b/src/libcamera/v4l2_videodevice.cpp > @@ -2042,10 +2042,8 @@ int V4L2VideoDevice::streamOff() > state_ = State::Stopping; > > /* Send back all queued buffers. */ > - for (auto it : queuedBuffers_) { > - FrameBuffer *buffer = it.second; > - > - cache_->put(it.first); > + for (auto [id, buffer] : queuedBuffers_) { > + cache_->put(id); > buffer->_d()->cancel(); > bufferReady.emit(buffer); > } > > base-commit: 1dcf9957a47fb54fce4fbae9daec0b587e52562e > -- > Regards, > > Laurent Pinchart >
2026. 02. 12. 13:35 keltezéssel, Laurent Pinchart írta: > Use structured bindings when iterating over a map in range-based for > loops. This improves readability. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/pipeline/ipu3/ipu3.cpp | 11 +++-------- > src/libcamera/pipeline/vimc/vimc.cpp | 3 +-- > src/libcamera/v4l2_videodevice.cpp | 6 ++---- > 3 files changed, 6 insertions(+), 14 deletions(-) > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp > index 0190f677e679..d1d4d85ebe76 100644 > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp > @@ -791,8 +791,7 @@ void IPU3CameraData::cancelPendingRequests() > while (!pendingRequests_.empty()) { > Request *request = pendingRequests_.front(); > > - for (auto it : request->buffers()) { > - FrameBuffer *buffer = it.second; > + for (auto [stream, buffer] : request->buffers()) { I think it might be better to default to `const auto&` as a rule of thumb to avoid copies. And I can also see a couple other hits for `for (const auto &it` and `for (auto const &it`, those might also be worth converting. Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > buffer->_d()->cancel(); > pipe()->completeBuffer(request, buffer); > } > @@ -1225,10 +1224,7 @@ void IPU3CameraData::paramsComputed(unsigned int id) > return; > > /* Queue all buffers from the request aimed for the ImgU. */ > - for (auto it : info->request->buffers()) { > - const Stream *stream = it.first; > - FrameBuffer *outbuffer = it.second; > - > + for (auto [stream, outbuffer] : info->request->buffers()) { > if (stream == &outStream_) > imgu_->output_->queueBuffer(outbuffer); > else if (stream == &vfStream_) > @@ -1304,8 +1300,7 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) > > /* If the buffer is cancelled force a complete of the whole request. */ > if (buffer->metadata().status == FrameMetadata::FrameCancelled) { > - for (auto it : request->buffers()) { > - FrameBuffer *b = it.second; > + for (auto [stream, b] : request->buffers()) { > b->_d()->cancel(); > pipe()->completeBuffer(request, b); > } > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp > index 4a03c149a617..025e7dbdd26f 100644 > --- a/src/libcamera/pipeline/vimc/vimc.cpp > +++ b/src/libcamera/pipeline/vimc/vimc.cpp > @@ -607,8 +607,7 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) > > /* If the buffer is cancelled force a complete of the whole request. */ > if (buffer->metadata().status == FrameMetadata::FrameCancelled) { > - for (auto it : request->buffers()) { > - FrameBuffer *b = it.second; > + for (auto [stream, b] : request->buffers()) { > b->_d()->cancel(); > pipe->completeBuffer(request, b); > } > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp > index 25b61d049a0e..02c50886a084 100644 > --- a/src/libcamera/v4l2_videodevice.cpp > +++ b/src/libcamera/v4l2_videodevice.cpp > @@ -2042,10 +2042,8 @@ int V4L2VideoDevice::streamOff() > state_ = State::Stopping; > > /* Send back all queued buffers. */ > - for (auto it : queuedBuffers_) { > - FrameBuffer *buffer = it.second; > - > - cache_->put(it.first); > + for (auto [id, buffer] : queuedBuffers_) { > + cache_->put(id); > buffer->_d()->cancel(); > bufferReady.emit(buffer); > } > > base-commit: 1dcf9957a47fb54fce4fbae9daec0b587e52562e
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0190f677e679..d1d4d85ebe76 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -791,8 +791,7 @@ void IPU3CameraData::cancelPendingRequests() while (!pendingRequests_.empty()) { Request *request = pendingRequests_.front(); - for (auto it : request->buffers()) { - FrameBuffer *buffer = it.second; + for (auto [stream, buffer] : request->buffers()) { buffer->_d()->cancel(); pipe()->completeBuffer(request, buffer); } @@ -1225,10 +1224,7 @@ void IPU3CameraData::paramsComputed(unsigned int id) return; /* Queue all buffers from the request aimed for the ImgU. */ - for (auto it : info->request->buffers()) { - const Stream *stream = it.first; - FrameBuffer *outbuffer = it.second; - + for (auto [stream, outbuffer] : info->request->buffers()) { if (stream == &outStream_) imgu_->output_->queueBuffer(outbuffer); else if (stream == &vfStream_) @@ -1304,8 +1300,7 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) /* If the buffer is cancelled force a complete of the whole request. */ if (buffer->metadata().status == FrameMetadata::FrameCancelled) { - for (auto it : request->buffers()) { - FrameBuffer *b = it.second; + for (auto [stream, b] : request->buffers()) { b->_d()->cancel(); pipe()->completeBuffer(request, b); } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 4a03c149a617..025e7dbdd26f 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -607,8 +607,7 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) /* If the buffer is cancelled force a complete of the whole request. */ if (buffer->metadata().status == FrameMetadata::FrameCancelled) { - for (auto it : request->buffers()) { - FrameBuffer *b = it.second; + for (auto [stream, b] : request->buffers()) { b->_d()->cancel(); pipe->completeBuffer(request, b); } diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 25b61d049a0e..02c50886a084 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -2042,10 +2042,8 @@ int V4L2VideoDevice::streamOff() state_ = State::Stopping; /* Send back all queued buffers. */ - for (auto it : queuedBuffers_) { - FrameBuffer *buffer = it.second; - - cache_->put(it.first); + for (auto [id, buffer] : queuedBuffers_) { + cache_->put(id); buffer->_d()->cancel(); bufferReady.emit(buffer); }
Use structured bindings when iterating over a map in range-based for loops. This improves readability. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/pipeline/ipu3/ipu3.cpp | 11 +++-------- src/libcamera/pipeline/vimc/vimc.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 6 ++---- 3 files changed, 6 insertions(+), 14 deletions(-) base-commit: 1dcf9957a47fb54fce4fbae9daec0b587e52562e