From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3919C4743D for ; Tue, 8 Jun 2021 16:12:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4F8A61183 for ; Tue, 8 Jun 2021 16:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbhFHQOB (ORCPT ); Tue, 8 Jun 2021 12:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbhFHQNw (ORCPT ); Tue, 8 Jun 2021 12:13:52 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA7EC061789 for ; Tue, 8 Jun 2021 09:11:47 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id t4-20020a1c77040000b029019d22d84ebdso2344786wmi.3 for ; Tue, 08 Jun 2021 09:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=IdQ1AZ3jf+euaUA6ZoFECd5OLFX5TngbTgmvbjYrSPw=; b=lNyvlJ9TYOpvl/iZXbDwY9bGHZqKO2IC54DN/dP37Zjh94GKHdPx4MLUl1X081Ck+i 0bZY0TBgmyAlhFGlVdrUQumblYt7hVf50iIqgX/+KOCohVLIa719JKAp4nD2OvqcMtFH eHLTDfiP4AUSskMYfRb9KeZgVx9AeVBVZ4UVXI36Yrzx5v7Yl2tKVbmQwyqOs4gurX77 Qj/kW0hYZFGnoVNeNJnzud4hI+dbpVdFCMF9TBhqbofC8rb1NMmObVGq0Gs8a9gdqhsw ubcx8M00ZI0g3x4NXlmXJ60MT0WAl7Qh6Wuo0kMVugh53RPMgCjbS5os2iywTOP8rsd1 9prw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=IdQ1AZ3jf+euaUA6ZoFECd5OLFX5TngbTgmvbjYrSPw=; b=ad9o0yfw//2lvljDTjMqo3Fet9+o62CCoPCZP4ASqCA3fKZRSeRbYuynMOOqFQhRPk Lmzl4IcBozWKVWu3WMYCs7kTxAjhIyjr9owLH2D1c6HxllCAtZhRonsYLRiENt8A+ZTW L1adl10R8ZqT70gJ8wqrNp4Z6BoxBtt0j8aIe3d/7iuLUPFhw/LiV5B4Fg5Q+6LLgUuW AJVCr3Wrst/nPlDq4MA6wI82rphuQsjycfLybBEbPE6CxjtoGn8P8ixls4tFlJwGSkvy ef3/FDTwBoYB4VKZLdYUbxo4KWDMJ4/8F3YW+AgCLXNy7NV5nsO1+eRQF9y+kM4F4jFF xoRg== X-Gm-Message-State: AOAM5335hQct3/RJugo526bDkAxxOxy6Iy3hpOLq9mbl/R11tlxdFLYj Io6cIFCjpg9D/1H/g5OfbvCJwAX2kCM= X-Google-Smtp-Source: ABdhPJw+KbrSzFmkomixUEwB1fDYrpdQf1E1YZb3VLvhzvAhUBPNm6dv0HU5MIl4iUSD2XvMB+KFBg== X-Received: by 2002:a05:600c:243:: with SMTP id 3mr22929881wmj.35.1623168705764; Tue, 08 Jun 2021 09:11:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j34sm3202000wms.19.2021.06.08.09.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 09:11:45 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Tue, 08 Jun 2021 16:11:40 +0000 Subject: [PATCH v4 2/4] diffcore-rename: avoid unnecessary strdup'ing in break_idx Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Jonathan Tan , Taylor Blau , =?UTF-8?Q?Ren=C3=A9?= Scharfe , Elijah Newren , Derrick Stolee , Jeff King , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren The keys of break_idx are strings from the diff_filepairs of diff_queued_diff. break_idx is only used in location_rename_dst(), and that usage is always before any free'ing of the pairs (and thus the strings in the pairs). As such, there is no need to strdup these keys; we can just reuse the existing strings as-is. The merge logic doesn't make use of break detection, so this does not affect the performance of any of my testcases. It was just a minor unrelated optimization noted in passing while looking at the code. Signed-off-by: Elijah Newren Reviewed-by: Derrick Stolee --- diffcore-rename.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diffcore-rename.c b/diffcore-rename.c index 3375e24659ea..e333a6d64791 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -54,7 +54,7 @@ static void register_rename_src(struct diff_filepair *p) if (p->broken_pair) { if (!break_idx) { break_idx = xmalloc(sizeof(*break_idx)); - strintmap_init(break_idx, -1); + strintmap_init_with_options(break_idx, -1, NULL, 0); } strintmap_set(break_idx, p->one->path, rename_dst_nr); } -- gitgitgadget