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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris

On 23/09/2022 19:55, Chris Poucet via GitGitGadget wrote:
From: Chris Poucet <poucet@xxxxxxxxxx>

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 <poucet@xxxxxxxxxx>
---
  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux