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>
This commit is contained in:
parent
e77a275110
commit
168bb3c97c
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue