Clean-up: sessiond: use empty() instead of comparing size to 0
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 12 Mar 2024 19:57:31 +0000 (15:57 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 12 Mar 2024 19:57:31 +0000 (15:57 -0400)
Harmonize the project's coding style a little by favoring the use of the
'empty()' methood of containers rather than comparing their size to 0.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I22e6b7fe4d94d8f43362fe119b4ca6d480587291

src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp
src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp

index 8da98591d6e0c731eea61d67199a8c859cef6b72..71a2e48d2190c29e0401c4876dda9322e815a456 100644 (file)
@@ -165,7 +165,7 @@ private:
                _fragment["alignment"] = type.alignment;
                _fragment["preferred-display-base"] = (unsigned int) type.base_;
 
-               if (type.roles_.size() > 0) {
+               if (!type.roles_.empty()) {
                        json::json role_array = json::json::array();
 
                        for (const auto role : type.roles_) {
@@ -201,7 +201,7 @@ private:
                _fragment["alignment"] = type.alignment;
                _fragment["preferred-display-base"] = (unsigned int) type.base_;
 
-               if (type.roles_.size() > 0) {
+               if (!type.roles_.empty()) {
                        if (std::is_signed<typename EnumerationType::mapping::range_t::
                                                   range_integer_t>::value) {
                                LTTNG_THROW_ERROR(
@@ -278,7 +278,7 @@ private:
                _fragment["type"] = "static-length-blob";
                _fragment["length"] = type.length_bytes;
 
-               if (type.roles_.size() > 0) {
+               if (!type.roles_.empty()) {
                        auto role_array = json::json::array();
 
                        for (const auto role : type.roles_) {
index c30f47efb18a3b900951cb1e172c7ede78ec056c..83f4a24274fc84cd47799bd2327be35713b2702d 100644 (file)
@@ -566,7 +566,7 @@ private:
        void visit(const lst::static_length_array_type& type) final
        {
                if (type.alignment != 0) {
-                       LTTNG_ASSERT(_current_field_name.size() > 0);
+                       LTTNG_ASSERT(!_current_field_name.empty());
                        _description += lttng::format(
                                "struct {{ }} align({alignment}) {field_name}_padding;\n",
                                fmt::arg("alignment", type.alignment),
@@ -587,7 +587,7 @@ private:
                         * could wrap nested sequences in structures, which
                         * would allow us to express alignment constraints.
                         */
-                       LTTNG_ASSERT(_current_field_name.size() > 0);
+                       LTTNG_ASSERT(!_current_field_name.empty());
                        _description += lttng::format(
                                "struct {{ }} align({alignment}) {field_name}_padding;\n",
                                fmt::arg("alignment", type.alignment),
@@ -676,7 +676,7 @@ private:
        void visit_variant(const lst::variant_type<MappingIntegerType>& type)
        {
                if (type.alignment != 0) {
-                       LTTNG_ASSERT(_current_field_name.size() > 0);
+                       LTTNG_ASSERT(!_current_field_name.empty());
                        _description += lttng::format(
                                "struct {{ }} align({alignment}) {field_name}_padding;\n",
                                fmt::arg("alignment", type.alignment),
This page took 0.027377 seconds and 4 git commands to generate.