From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 69D3B1F5AE for ; Thu, 25 Jun 2020 19:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406877AbgFYTs1 (ORCPT ); Thu, 25 Jun 2020 15:48:27 -0400 Received: from cloud.peff.net ([104.130.231.41]:43308 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406866AbgFYTs1 (ORCPT ); Thu, 25 Jun 2020 15:48:27 -0400 Received: (qmail 31409 invoked by uid 109); 25 Jun 2020 19:48:27 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Thu, 25 Jun 2020 19:48:27 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 19646 invoked by uid 111); 25 Jun 2020 19:48:27 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Thu, 25 Jun 2020 15:48:27 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 25 Jun 2020 15:48:25 -0400 From: Jeff King To: git@vger.kernel.org Cc: Eric Sunshine , Junio C Hamano , Johannes Schindelin , SZEDER =?utf-8?B?R8OhYm9y?= Subject: [PATCH v2 06/11] fast-export: use a flex array to store anonymized entries Message-ID: <20200625194825.GF4029374@coredump.intra.peff.net> References: <20200625194802.GA4028913@coredump.intra.peff.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200625194802.GA4028913@coredump.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we're using a separate keydata struct for hash lookups, we have more flexibility in how we allocate anonymized_entry structs. Let's push the "orig" key into a flex member within the struct. That should save us a few bytes of memory per entry (a pointer plus any malloc overhead), and may make lookups a little faster (since it's one less pointer to chase in the comparison function). Signed-off-by: Jeff King --- builtin/fast-export.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 5df2ada47d..99d4a2b404 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -120,8 +120,8 @@ static int has_unshown_parent(struct commit *commit) struct anonymized_entry { struct hashmap_entry hash; - const char *orig; const char *anon; + const char orig[FLEX_ARRAY]; }; struct anonymized_entry_key { @@ -170,9 +170,8 @@ static const char *anonymize_str(struct hashmap *map, ret = hashmap_get_entry(map, &key, hash, &key); if (!ret) { - ret = xmalloc(sizeof(*ret)); + FLEX_ALLOC_MEM(ret, orig, orig, len); hashmap_entry_init(&ret->hash, key.hash.hash); - ret->orig = xmemdupz(orig, len); ret->anon = generate(orig, len); hashmap_put(map, &ret->hash); } -- 2.27.0.593.gb3082a2aaf