Re: [PATCH v3 13/13] Use new HASHMAP_INIT macro to simplify hashmap initialization
- From
Jeff King <peff@peff.net>
- Date
- Nov 4, 2020, 20:48 UTC
- Message-ID
- <20201104204809.GE3629238@coredump.intra.peff.net>
- In-Reply-To
- <5f41fc63e5355121cf882f63e1b38b8df1948df8.1604343314.git.gitgitgadget@gmail.com>
On Mon, Nov 02, 2020 at 06:55:13PM +0000, Elijah Newren via GitGitGadget wrote:
Show 6 quoted lines
> From: Elijah Newren <newren@gmail.com> > > Now that hashamp has lazy initialization and a HASHMAP_INIT macro, > hashmaps allocated on the stack can be initialized without a call to > hashmap_init() and in some cases makes the code a bit shorter. Convert > some callsites over to take advantage of this.
These all look obviously correct. I suspect there are more, but there's no need for us to be thorough at this point.
Show 8 quoted lines
> --- a/range-diff.c
> +++ b/range-diff.c
> @@ -232,11 +232,9 @@ static int patch_util_cmp(const void *dummy, const struct patch_util *a,
>
> static void find_exact_matches(struct string_list *a, struct string_list *b)
> {
> - struct hashmap map;
> + struct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);Not related to your patch, but we should in general try to define these comparison functions with the correct signature, rather than cast them.
I think I've already inflated your series enough, so let's leave it for now, but just a mental note that it might be useful to circle back and fix these en masse (I know we cleaned up several a while back, so I'm actually surprised to see one still here).
-Peff