From: Patrick Steinhardt <ps@pks.im>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/3] oidmap: add size function
Date: Tue, 13 May 2025 11:48:36 +0200 [thread overview]
Message-ID: <aCMVdEg8d6BHo7AA@pks.im> (raw)
In-Reply-To: <20250512185130.GB1276214@coredump.intra.peff.net>
On Mon, May 12, 2025 at 02:51:30PM -0400, Jeff King wrote:
> Callers which want to know how many items are in an oidmap have to look
> at the underlying hashmap struct, leaking an implementation detail.
> Let's provide a type-appropriate wrapper and use it.
>
> Note in the call from lookup_replace_object(), the caller was actually
> looking at the hashmap's tablesize parameter (the allocated size of the
> table) rather than hashmap_get_size(), the number of items in the table.
> This probably should have been checking the number of items all along,
> but the two are functionally equivalent here since we only add to the
> map and never remove anything. Thus if there was any allocation, it was
> because there is at least one item.
I was a bit puzzled by this explanation initially. The two sizes aren't
functioally equivalent -- the table size will typically be larger than
the number of contained entries. But the thing is that we don't care for
the actual size, we only care whether the map is empty or not. And for
that those are indeed equivalent in this specific case.
Patrick
next prev parent reply other threads:[~2025-05-13 9:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 18:50 [PATCH 0/3] minor oidmap cleanups Jeff King
2025-05-12 18:50 ` [PATCH 1/3] oidmap: rename oidmap_free() to oidmap_clear() Jeff King
2025-05-12 18:51 ` [PATCH 2/3] oidmap: add size function Jeff King
2025-05-13 9:48 ` Patrick Steinhardt [this message]
2025-05-14 17:59 ` Jeff King
2025-05-12 18:52 ` [PATCH 3/3] raw_object_store: drop extra pointer to replace_map Jeff King
2025-05-13 9:48 ` Patrick Steinhardt
2025-05-14 14:38 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aCMVdEg8d6BHo7AA@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).