Re: [PATCH 02/10] sha1-array: implement oid_array_readonly_contains
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Sep 26, 2022, 13:08 UTC
- Message-ID
- <2d886c19-09a8-c3cb-308b-b30ece02fb32@gmail.com>
- In-Reply-To
- <84588312c1d4a62ff6c6211e85b4e58ab0563daa.1663959324.git.gitgitgadget@gmail.com>
Hi Chris
On 23/09/2022 19:55, Chris Poucet via GitGitGadget wrote:
Show 9 quoted lines
> From: Chris Poucet <poucet@google.com> > > 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.
Show 19 quoted lines
> Signed-off-by: Chris Poucet <poucet@google.com>
> ---
> 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