mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-20 02:45:08 +03:00
libcamera: controls: Avoid double lookups
Now that the ControlList::get() function returns an instance of std::optional<>, we can replace the ControlList::contains() calls with a nullopt check on the return value of get(). This avoids double lookups of controls through the code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
parent
1c4d480185
commit
f995ff25a3
7 changed files with 72 additions and 76 deletions
|
@ -300,8 +300,9 @@ std::string CamApp::cameraName(const Camera *camera)
|
|||
* Construct the name from the camera location, model and ID. The model
|
||||
* is only used if the location isn't present or is set to External.
|
||||
*/
|
||||
if (props.contains(properties::Location)) {
|
||||
switch (*props.get(properties::Location)) {
|
||||
const auto &location = props.get(properties::Location);
|
||||
if (location) {
|
||||
switch (*location) {
|
||||
case properties::CameraLocationFront:
|
||||
addModel = false;
|
||||
name = "Internal front camera ";
|
||||
|
@ -316,12 +317,14 @@ std::string CamApp::cameraName(const Camera *camera)
|
|||
}
|
||||
}
|
||||
|
||||
if (addModel && props.contains(properties::Model)) {
|
||||
if (addModel) {
|
||||
/*
|
||||
* If the camera location is not availble use the camera model
|
||||
* to build the camera name.
|
||||
*/
|
||||
name = "'" + *props.get(properties::Model) + "' ";
|
||||
const auto &model = props.get(properties::Model);
|
||||
if (model)
|
||||
name = "'" + *model + "' ";
|
||||
}
|
||||
|
||||
name += "(" + camera->id() + ")";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue