From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3LmQzYggKCtsDMOL9FA7DLLDIB.9LJIF878FD7FIPLRO9BT7OB.LOD@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 AD5EE3858401 for ; Thu, 17 Mar 2022 16:39:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD5EE3858401 Received: by mail-ej1-x64a.google.com with SMTP id m12-20020a1709062acc00b006cfc98179e2so3228365eje.6 for ; Thu, 17 Mar 2022 09:39:11 -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=97sbJG6epk6xgM6PR2EhU60ZnF/WkzV5P0dALsI2fbs=; b=NpxIcXRL20UGKCdr7VsWLArm8aeKYWHJ0B2W3JAtrmpJbvOrvHKY9ypXL2EXB6KnYD mQXWL3JjoHt6ZJDvh470b0V3r62Bp1NXwKicMjFMTrxT34xGdCAGr6HHWeOUjQRNItOL SrrTrt0EKl0JhZg5CKqq1fQVYQlGVpQx5xXsoWA22SKe2htxjsS8CGjvBt0+POocVeoH hEOUWHwx5P1SbhVYVvHHR0XXVNc6IKaVxak6n1nkp7M0VFnQqWxhpCVOC3RG+4y8WiLc ognyWgdqU8AdiL3cCqfk1Iaei3pMJ7+DmRkLGDR3n2wGhAaFAlbnxbFe6YF+zpfNNQmJ wT9g== X-Gm-Message-State: AOAM533ft6Ps3rAwY5yRUUbQJ+pJNicsne9XaO5A3g+kdcjACuO3cDiT 85AHJ55BKvqfdiT5afCU+oQZD58EoEE215a2h5BlmDFl+Ufx/LcWeiixQFlTbfDk8nsy05iDLfs JShYIcl4xfq+1/jHUaZlooaNUHzKFHySn0TGMcWUNDWkY5yFyiYwMiZ6GCONaUDd0NiT1UJ4= X-Google-Smtp-Source: ABdhPJzng5H9A3bhl0cLHvw/ZnsbytBqqhEpddfIOhua62Wr8X/lJeqL4BS+I40H+sJ6Y4Cjsdmzn1XRe/o0sA== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:cfc0:be7d:c8f5:f085]) (user=gprocida job=sendgmr) by 2002:a17:907:1692:b0:6df:a6ce:e2dc with SMTP id hc18-20020a170907169200b006dfa6cee2dcmr2093100ejc.67.1647535150526; Thu, 17 Mar 2022 09:39:10 -0700 (PDT) Date: Thu, 17 Mar 2022 16:38:55 +0000 In-Reply-To: <20220317163858.353762-1-gprocida@google.com> Message-Id: <20220317163858.353762-2-gprocida@google.com> Mime-Version: 1.0 References: <20220316163055.4127796-1-gprocida@google.com> <20220317163858.353762-1-gprocida@google.com> X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH v3 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.0 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 17 Mar 2022 16:39:13 -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.35.1.894.gb6a874cedc-goog