Message ID | 20240520035232.205777-1-pobrn@protonmail.com |
---|---|
State | Accepted |
Commit | 168bb3c97c5f338486251ae7752bccd4e61ffcc0 |
Headers | show |
Series |
|
Related | show |
2024. május 20., hétfő 5:52 keltezéssel, Barnabás Pőcze <pobrn@protonmail.com> írta: > `YamlObject::contains()` does the same search, > doing the lookup twice in unnecessary. Oops, this should say "is" instead of "in". > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> > --- > src/libcamera/yaml_parser.cpp | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > 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; > } > > -- > 2.45.1
Quoting Barnabás Pőcze (2024-05-20 04:55:43) > 2024. május 20., hétfő 5:52 keltezéssel, Barnabás Pőcze <pobrn@protonmail.com> írta: > > > `YamlObject::contains()` does the same search, > > doing the lookup twice in unnecessary. > > Oops, this should say "is" instead of "in". Can be fixed while applying to avoid the need for a v2. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> > > --- > > src/libcamera/yaml_parser.cpp | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > 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; > > } > > > > -- > > 2.45.1
Hi Barnabas - thanks for the patch On 20/05/2024 04:52, Barnabás Pőcze wrote: > `YamlObject::contains()` does the same search, > doing the lookup twice in unnecessary. > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> > --- > src/libcamera/yaml_parser.cpp | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > 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; > } >
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; }
`YamlObject::contains()` does the same search, doing the lookup twice in unnecessary. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> --- src/libcamera/yaml_parser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)