]> sourceware.org Git - libabigail.git/commitdiff
abg-comparison: prefer .empty() over implicit bool conversion of .size()
authorMatthias Maennich <maennich@google.com>
Wed, 29 Jan 2020 15:31:26 +0000 (15:31 +0000)
committerMatthias Maennich <maennich@google.com>
Mon, 3 Feb 2020 14:39:39 +0000 (14:39 +0000)
size() is not guaranteed to be a constant-time function. Also, using
.empty() shows clearer intent. Hence switch to using .empty().
That issue was flagged by clang-tidy[1].

* src/abg-comparison.cc (corpus_diff::has_changes): prefer
!container.empty() over bool(container.size())

[1] https://clang.llvm.org/extra/clang-tidy/checks/readability-container-size-empty.html

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
src/abg-comparison.cc

index 06745d310f20f0d5349acf44af0e97079e5546f5..af4cd5e743496f539f9f5f8e99769a1e01c71877 100644 (file)
@@ -10530,19 +10530,19 @@ corpus_diff::has_changes() const
 {
   return (soname_changed()
          || architecture_changed()
-         || priv_->deleted_fns_.size()
-         || priv_->added_fns_.size()
-         || priv_->changed_fns_map_.size()
-         || priv_->deleted_vars_.size()
-         || priv_->added_vars_.size()
-         || priv_->changed_vars_map_.size()
-         || priv_->added_unrefed_fn_syms_.size()
-         || priv_->deleted_unrefed_fn_syms_.size()
-         || priv_->added_unrefed_var_syms_.size()
-         || priv_->deleted_unrefed_var_syms_.size()
-         || priv_->deleted_unreachable_types_.size()
-         || priv_->added_unreachable_types_.size()
-         || priv_->changed_unreachable_types_.size());
+         || !(priv_->deleted_fns_.empty()
+              && priv_->added_fns_.empty()
+              && priv_->changed_fns_map_.empty()
+              && priv_->deleted_vars_.empty()
+              && priv_->added_vars_.empty()
+              && priv_->changed_vars_map_.empty()
+              && priv_->added_unrefed_fn_syms_.empty()
+              && priv_->deleted_unrefed_fn_syms_.empty()
+              && priv_->added_unrefed_var_syms_.empty()
+              && priv_->deleted_unrefed_var_syms_.empty()
+              && priv_->deleted_unreachable_types_.empty()
+              && priv_->added_unreachable_types_.empty()
+              && priv_->changed_unreachable_types_.empty()));
 }
 
 /// Test if the current instance of @ref corpus_diff carries changes
This page took 0.095634 seconds and 5 git commands to generate.