Subject: Re: [PATCH 02/10] sha1-array: implement oid_array_readonly_contains

From: Phillip Wood <[email-masked]>
Date: Mon, 26 Sep 2022 14:08:17 +0100

Hi Chris

On 23/09/2022 19:55, Chris Poucet via GitGitGadget wrote:
> From: Chris Poucet <[email-masked]>
> 
> Implement a "readonly_contains" function for oid_array that won't
> sort the array if it is unsorted. This can be used to test containment in
> the rare situations where the array order matters.
> 
> The function has intentionally been given a name that is more cumbersome
> than the "lookup" function, which is what most callers will will want
> in most situations.

It certainly is more cumbersome. I also find it completely impenetrable, 
I wonder if lookup_unsorted or lookup_no_sort strike better balance 
between being cumbersome and descriptive.

> Signed-off-by: Chris Poucet <[email-masked]>
> ---
>   oid-array.c               | 12 ++++++++++++
>   oid-array.h               |  7 +++++++
>   t/helper/test-oid-array.c |  6 ++++++
>   t/t0064-oid-array.sh      | 22 ++++++++++++++++++++++
>   4 files changed, 47 insertions(+)
> 
> diff --git a/oid-array.c b/oid-array.c
> index 73ba76e9e9a..1e12651d245 100644
> --- a/oid-array.c
> +++ b/oid-array.c
> @@ -28,6 +28,18 @@ static const struct object_id *oid_access(size_t index, const void *table)
>   	return &array[index];
>   }
>   
> +int oid_array_readonly_contains(const struct oid_array *array,
> +				const struct object_id* oid) {
> +	int i;

array->nr is size_t so i should be as well.

Best Wishes

Phillip