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

From
Phillip Wood <hidden>
Date
2022-09-26 14:45:46
Reply to
Chris Poucet via GitGitGadget, 2022-09-23
Hi Chris

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

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.
quoted hunk ↗ jump to hunk
Signed-off-by: Chris Poucet <redacted>
---
  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
Thread (65 messages) 65 messages, 10 authors, last reply 2022-10-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help