From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3kqE4YggKCs81AC9x3yv19916z.x9763wvw31v36D9FCxzHvCz.9C1@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 448423857419 for ; Mon, 21 Mar 2022 16:02:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 448423857419 Received: by mail-ej1-x64a.google.com with SMTP id hy26-20020a1709068a7a00b006dfa034862cso5064157ejc.23 for ; Mon, 21 Mar 2022 09:02:28 -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=mKOv3MQCiOot4zYxyDmAkLXmfU1/IYJg8YVHrWw0m/x18QEgmeEQvVBupeSazh/w61 DZw77lHDCCYm4ZDE9H1wdViHzE5h3DJSXS4L42fTo9S1B5X/RZZ68Os0oxYacrFrUpcs ZJXFOrF35nvnLOHYynnPc0TQF6chU4GkJiLLi+fnrsjWETJA1UjFhF9GVAYGq0GcznKR t+fTCVd/AhVE5fiROhUvhmcSoIKr5E+GblDyXLyyvE0hHyKftfGWHVwS8mIogC76IA+z 116weVLK+hNOrdmMfzNzuW8tZlWLq6/M1/KjopNbWpZT/Lthhrj1BdkRRZ3+gqyJIzI6 6xZQ== X-Gm-Message-State: AOAM530VbxSZfPcomaZgyRgN9s0LUAuFi2S1WXIhHM0RNpXCXUD8GAdd XJgTxCG9voy4Xg87p+5jmdIF/IY51Xfix2+C9fR3C9fRw3mu5pNFC0h56oXOhPL8K37icWcjHYg LqQIY4RntyIUIZrw2hw1K01HkbMXHz8zJh+7c5WVfYl2Uow81mNR39KJKNR132GveWL62r20= X-Google-Smtp-Source: ABdhPJxhZneo4b77upzwXGOZiD4Ht3u2dvMRqvYS0VOkPS5XuMi/Ca2HkKXJH74Wm04plhC4pXYiWHqSN13z5g== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:45b0:e68c:9bc8:4749]) (user=gprocida job=sendgmr) by 2002:a17:906:1f11:b0:685:d50e:3bf9 with SMTP id w17-20020a1709061f1100b00685d50e3bf9mr22177860ejj.275.1647878546970; Mon, 21 Mar 2022 09:02:26 -0700 (PDT) Date: Mon, 21 Mar 2022 16:02:18 +0000 In-Reply-To: <20220321160221.1372398-1-gprocida@google.com> Message-Id: <20220321160221.1372398-2-gprocida@google.com> Mime-Version: 1.0 References: <20220317163858.353762-1-gprocida@google.com> <20220321160221.1372398-1-gprocida@google.com> X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH v4 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.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: Mon, 21 Mar 2022 16:02:29 -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