From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <37UinYggKCjgajliWcXUaiiafY.WigfcVUVcaUcfmiolWYqUlY.ila@flex--gprocida.bounces.google.com> Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by sourceware.org (Postfix) with ESMTPS id BFCBD385AE75 for ; Mon, 13 Jun 2022 14:25:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFCBD385AE75 Received: by mail-ej1-x64a.google.com with SMTP id n2-20020a170906724200b006fed87ccbb8so1874179ejk.7 for ; Mon, 13 Jun 2022 07:25:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=M796snr00vGwrsrcjnYB/2VdsoZiuXokE+SaZbDtpOs=; b=yudHU9scA6RakH3m8NVfV3MpDnLJv3S0fMTYM1Mvie9UgQ9Xlngaq7+Q/9JnJscb93 kkK7uVwjA8s2nTlfWENbVlXvgZNwxZq5SU7/zFiZWYVQL1xQwqGttzvkGTxzyeFSw5YC P4RdUk8bxAtP7YhiJHYkh/SSgR2i9oBb7jOyFrca7Ew84Laz0qU2rKTrsKMqViLfdAUr sQBOk+6BZ/myCke9usDBTAx1u6+yNRA11Mlm253WV2QBzfeR0vlFbyCrW1ABnXuD3rGh RfVq93PpWpGRrv+9EVv+Sj9M1cpaan86oHWEycKiRLtuDd1zodtH1LDOcbT8ntvXqA4D Ax6A== X-Gm-Message-State: AOAM530pdrd0HYlB3VK27nLFhhJbJmkX+kqAby+92x9zDaur+6nhKKWQ QbuGU/FhhlkIIQncVshsC/AXHW/0rQ5Hx8TF+3gpfoUp5QhAlsQhqXoPOfM6G42pgqwV7+J2Uq7 Lw7Pc3S4PuXBzMByor7WuwzfyvH3/Gy8xUNTWWdE1xjTRqK+/WvLtpk+WMswQKKXz8OnPLjU= X-Google-Smtp-Source: AGRyM1sPS4RYPiSwPnJU1AIJ2kwy6hGJIBzPEMupYa7r8Rm4hmZqjD8nH31r2OzYpL8zwYVTE9fczpqECKNcvg== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:209:8336:7478:639d:964a]) (user=gprocida job=sendgmr) by 2002:a17:906:2885:b0:711:4611:95cc with SMTP id o5-20020a170906288500b00711461195ccmr153829ejd.38.1655130349497; Mon, 13 Jun 2022 07:25:49 -0700 (PDT) Date: Mon, 13 Jun 2022 15:25:30 +0100 In-Reply-To: <20220321160221.1372398-1-gprocida@google.com> Message-Id: <20220613142533.3676501-2-gprocida@google.com> Mime-Version: 1.0 References: <20220321160221.1372398-1-gprocida@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH v5 1/4] crc_changed: eliminate copying of shared_ptr values From: Giuliano Procida To: libabigail@sourceware.org Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com, maennich@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-21.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2022 14:25:52 -0000 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. Reviewed-by: Matthias Maennich Signed-off-by: Giuliano Procida --- 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.36.1.476.g0c4daa206d-goog