public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] abg-comparison: prefer .empty() over implicit bool conversion of .size()
  2020-01-01  0:00 ` Dodji Seketeli
@ 2020-01-01  0:00   ` Matthias Maennich via libabigail
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Maennich via libabigail @ 2020-01-01  0:00 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: libabigail, kernel-team

On Mon, Feb 03, 2020 at 11:28:08AM +0100, Dodji Seketeli wrote:
>Hello,
>
>Matthias Maennich <maennich@google.com> a écrit:
>
>> 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())
>
>This is obviously OK to commit to master.
>
>Thanks!

Thanks! Applied to master!

Cheers,
Matthias

>
>-- 
>		Dodji

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] abg-comparison: prefer .empty() over implicit bool conversion of .size()
  2020-01-01  0:00 [PATCH] abg-comparison: prefer .empty() over implicit bool conversion of .size() Matthias Maennich via libabigail
@ 2020-01-01  0:00 ` Dodji Seketeli
  2020-01-01  0:00   ` Matthias Maennich via libabigail
  0 siblings, 1 reply; 3+ messages in thread
From: Dodji Seketeli @ 2020-01-01  0:00 UTC (permalink / raw)
  To: Matthias Maennich; +Cc: libabigail, kernel-team

Hello,

Matthias Maennich <maennich@google.com> a écrit:

> 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())

This is obviously OK to commit to master.

Thanks!

-- 
		Dodji

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] abg-comparison: prefer .empty() over implicit bool conversion of .size()
@ 2020-01-01  0:00 Matthias Maennich via libabigail
  2020-01-01  0:00 ` Dodji Seketeli
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Maennich via libabigail @ 2020-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, maennich

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 --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
-- 
2.25.0.341.g760bfbb309-goog

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-03 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [PATCH] abg-comparison: prefer .empty() over implicit bool conversion of .size() Matthias Maennich via libabigail
2020-01-01  0:00 ` Dodji Seketeli
2020-01-01  0:00   ` Matthias Maennich via libabigail

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).