diff mbox series

abg-comparison: prefer .empty() over implicit bool conversion of .size()

Message ID 20200129153838.73185-1-maennich@google.com
State Committed
Headers show
Series abg-comparison: prefer .empty() over implicit bool conversion of .size() | expand

Commit Message

Matthias Maennich via libabigail Jan. 1, 2020, midnight UTC
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

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-comparison.cc | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc
index 06745d310f20..af4cd5e74349 100644
--- a/src/abg-comparison.cc
+++ b/src/abg-comparison.cc
@@ -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