public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
	 maennich@google.com
Subject: [PATCH v2 2/4] crc_changed: eliminate copying of shared_ptr values
Date: Wed, 16 Mar 2022 16:30:53 +0000	[thread overview]
Message-ID: <20220316163055.4127796-3-gprocida@google.com> (raw)
In-Reply-To: <20220316163055.4127796-1-gprocida@google.com>

As pointed out in a review of similar code, it is possible to avoid
copying a couple of shared pointers in this function, by taking
references instead.

This commit also splits declarations to one per line and removes the
unnecessary parentheses around the return expression.

	* src/abg-comp-filter.cc (crc_changed): Take references to
	avoid std::shared_ptr copying. Split declarations into one per
	line. Remove unnecessary return expression parentheses.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-comp-filter.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/abg-comp-filter.cc b/src/abg-comp-filter.cc
index 56251274..f90fdc78 100644
--- a/src/abg-comp-filter.cc
+++ b/src/abg-comp-filter.cc
@@ -230,11 +230,13 @@ static bool
 crc_changed(const function_or_var_decl_sptr& f,
 	    const function_or_var_decl_sptr& s)
 {
-  const auto symbol_f  = f->get_symbol(), symbol_s = s->get_symbol();
+  const auto& symbol_f = f->get_symbol();
+  const auto& symbol_s = s->get_symbol();
   if (!symbol_f || !symbol_s)
     return false;
-  const auto crc_f = symbol_f->get_crc(), crc_s = symbol_s->get_crc();
-  return (crc_f != 0 && crc_s != 0 && crc_f != crc_s);
+  const auto crc_f = symbol_f->get_crc();
+  const auto crc_s = symbol_s->get_crc();
+  return crc_f != 0 && crc_s != 0 && crc_f != crc_s;
 }
 
 /// Test if the current diff tree node carries a CRC change in either a
-- 
2.35.1.894.gb6a874cedc-goog


  parent reply	other threads:[~2022-03-16 16:31 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 18:13 [PATCH 0/2] Bug 28954 - add Linux Kernel symbol namespace support Giuliano Procida
2022-03-14 18:13 ` [PATCH 1/2] optional: add operator== and operator!= Giuliano Procida
2022-03-15 11:02   ` Matthias Maennich
2022-03-16  9:31     ` Giuliano Procida
2022-03-14 18:13 ` [PATCH 2/2] add Linux kernel symbol namespace support Giuliano Procida
2022-03-15 11:25   ` Matthias Maennich
2022-03-16 16:30 ` [PATCH v2 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-16 16:30   ` [PATCH v2 1/4] optional: minor improvements Giuliano Procida
2022-03-17 10:56     ` Matthias Maennich
2022-03-16 16:30   ` Giuliano Procida [this message]
2022-03-17 11:01     ` [PATCH v2 2/4] crc_changed: eliminate copying of shared_ptr values Matthias Maennich
2022-03-16 16:30   ` [PATCH v2 3/4] add Linux kernel symbol namespace support Giuliano Procida
2022-03-17 11:57     ` Matthias Maennich
2022-03-16 16:30   ` [PATCH v2 4/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-17 12:01     ` Matthias Maennich
2022-03-17 16:38   ` [PATCH v3 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 2/4] optional: minor improvements Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-03-21 12:53       ` Matthias Maennich
2022-03-21 15:52         ` Giuliano Procida
2022-03-21 16:02     ` [PATCH v4 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 2/4] optional: minor improvements Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-06-13 14:25       ` [PATCH v5 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-06-30 16:39         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-06-30 16:40         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 2/4] optional: minor improvements Giuliano Procida
2022-06-30 16:40         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-06-30 16:41         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-07-01 12:54         ` Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220316163055.4127796-3-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).