Message ID | 20241215223947.7779-1-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Commit | a7aab7da8a716299661b5f451366fb6e2f3d88b2 |
Headers | show |
Series |
|
Related | show |
On Mon, Dec 16, 2024 at 12:39:47AM +0200, Laurent Pinchart wrote: > Comparing a std::string to an empty string literal is more complex than > using the std::string::empty() function. Improve the code efficiency by > replacing the former with the latter. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > src/libcamera/yaml_parser.cpp | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp > index 5ca5fb8235b5e761..a5e424615c263f2d 100644 > --- a/src/libcamera/yaml_parser.cpp > +++ b/src/libcamera/yaml_parser.cpp > @@ -194,7 +194,7 @@ YamlObject::Getter<double>::get(const YamlObject &obj) const > if (obj.type_ != Type::Value) > return std::nullopt; > > - if (obj.value_ == "") > + if (obj.value_.empty()) > return std::nullopt; > > char *end; > > base-commit: 8e15010b7dfa9c2a68dd57f924b5603784be0e09
Quoting Paul Elder (2024-12-16 06:49:47) > On Mon, Dec 16, 2024 at 12:39:47AM +0200, Laurent Pinchart wrote: > > Comparing a std::string to an empty string literal is more complex than > > using the std::string::empty() function. Improve the code efficiency by > > replacing the former with the latter. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > > --- > > src/libcamera/yaml_parser.cpp | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp > > index 5ca5fb8235b5e761..a5e424615c263f2d 100644 > > --- a/src/libcamera/yaml_parser.cpp > > +++ b/src/libcamera/yaml_parser.cpp > > @@ -194,7 +194,7 @@ YamlObject::Getter<double>::get(const YamlObject &obj) const > > if (obj.type_ != Type::Value) > > return std::nullopt; > > > > - if (obj.value_ == "") > > + if (obj.value_.empty()) > > return std::nullopt; > > > > char *end; > > > > base-commit: 8e15010b7dfa9c2a68dd57f924b5603784be0e09
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index 5ca5fb8235b5e761..a5e424615c263f2d 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -194,7 +194,7 @@ YamlObject::Getter<double>::get(const YamlObject &obj) const if (obj.type_ != Type::Value) return std::nullopt; - if (obj.value_ == "") + if (obj.value_.empty()) return std::nullopt; char *end;
Comparing a std::string to an empty string literal is more complex than using the std::string::empty() function. Improve the code efficiency by replacing the former with the latter. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/yaml_parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 8e15010b7dfa9c2a68dd57f924b5603784be0e09