summaryrefslogtreecommitdiff
path: root/src/libcamera
diff options
context:
space:
mode:
authorBarnabás Pőcze <pobrn@protonmail.com>2024-05-20 03:52:33 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2024-05-21 13:23:12 +0100
commit168bb3c97c5f338486251ae7752bccd4e61ffcc0 (patch)
tree6320da73dff5212a42f7f31be6fca9823463dff5 /src/libcamera
parente77a2751100e38eb294f2694d9b1d100449a2770 (diff)
libcamera: yaml_parser: Avoid double lookup in `operator[]`
`YamlObject::contains()` does the same search, doing the lookup twice is unnecessary. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera')
-rw-r--r--src/libcamera/yaml_parser.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index 55f81916..aac9a2bd 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -468,10 +468,13 @@ bool YamlObject::contains(const std::string &key) const
*/
const YamlObject &YamlObject::operator[](const std::string &key) const
{
- if (type_ != Type::Dictionary || !contains(key))
+ if (type_ != Type::Dictionary)
return empty;
auto iter = dictionary_.find(key);
+ if (iter == dictionary_.end())
+ return empty;
+
return *iter->second;
}