libcamera: request: Avoid double map lookup
Use `try_emplace()` that more or less combines `find()` and `operator[]` in one function. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
7fd317adf0
commit
5553efc6b1
1 changed files with 2 additions and 3 deletions
|
@ -484,15 +484,14 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,
|
|||
return -EEXIST;
|
||||
}
|
||||
|
||||
auto it = bufferMap_.find(stream);
|
||||
if (it != bufferMap_.end()) {
|
||||
auto [it, inserted] = bufferMap_.try_emplace(stream, buffer);
|
||||
if (!inserted) {
|
||||
LOG(Request, Error) << "FrameBuffer already set for stream";
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
buffer->_d()->setRequest(this);
|
||||
_d()->pending_.insert(buffer);
|
||||
bufferMap_[stream] = buffer;
|
||||
|
||||
if (fence && fence->isValid())
|
||||
buffer->_d()->setFence(std::move(fence));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue