diff mbox series

[v2,11/19] midx: remove unused `midx_locate_pack()`

Message ID 22de5898f3fec0cfff4289660b5f52aa31533fe1.1721250704.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series midx: incremental multi-pack indexes, part one | expand

Commit Message

Taylor Blau July 17, 2024, 9:12 p.m. UTC
Commit 307d75bbe6 (midx: implement `midx_locate_pack()`, 2023-12-14)
introduced `midx_locate_pack()`, which was described at the time as a
complement to the function `midx_contains_pack()` which allowed
callers to determine where in the MIDX lexical order a pack appeared, as
opposed to whether or not it was simply contained.

307d75bbe6 suggests that future patches would be added which would
introduce callers for this new function, but none ever were, meaning the
function has gone unused since its introduction.

Clean this up by in effect reverting 307d75bbe6, which removes the
unused functions and inlines its definition back into
`midx_contains_pack()`.

(Looking back through the list archives when 307d75bbe6 was written,
this was in preparation for this[1] patch from back when we had the
concept of "disjoint" packs while developing multi-pack verbatim reuse.
That concept was abandoned before the series was merged, but I never
dropped what would become 307d75bbe6 from the series, leading to the
state prior to this commit).

[1]: https://lore.kernel.org/git/3019738b52ba8cd78ea696a3b800fa91e722eb66.1701198172.git.me@ttaylorr.com/

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 midx.c | 13 ++-----------
 midx.h |  2 --
 2 files changed, 2 insertions(+), 13 deletions(-)

Comments

Jeff King Aug. 1, 2024, 10:14 a.m. UTC | #1
On Wed, Jul 17, 2024 at 05:12:29PM -0400, Taylor Blau wrote:

> Commit 307d75bbe6 (midx: implement `midx_locate_pack()`, 2023-12-14)
> introduced `midx_locate_pack()`, which was described at the time as a
> complement to the function `midx_contains_pack()` which allowed
> callers to determine where in the MIDX lexical order a pack appeared, as
> opposed to whether or not it was simply contained.
> 
> 307d75bbe6 suggests that future patches would be added which would
> introduce callers for this new function, but none ever were, meaning the
> function has gone unused since its introduction.
> 
> Clean this up by in effect reverting 307d75bbe6, which removes the
> unused functions and inlines its definition back into
> `midx_contains_pack()`.
> 
> (Looking back through the list archives when 307d75bbe6 was written,
> this was in preparation for this[1] patch from back when we had the
> concept of "disjoint" packs while developing multi-pack verbatim reuse.
> That concept was abandoned before the series was merged, but I never
> dropped what would become 307d75bbe6 from the series, leading to the
> state prior to this commit).
> 
> [1]: https://lore.kernel.org/git/3019738b52ba8cd78ea696a3b800fa91e722eb66.1701198172.git.me@ttaylorr.com/

Nice description of the history. I wish all patches which said "eh, this
is unused, let's remove it" went to the same trouble to make sure we
aren't missing something subtle.

-Peff
Taylor Blau Aug. 1, 2024, 8:01 p.m. UTC | #2
On Thu, Aug 01, 2024 at 06:14:54AM -0400, Jeff King wrote:
> Nice description of the history. I wish all patches which said "eh, this
> is unused, let's remove it" went to the same trouble to make sure we
> aren't missing something subtle.

:-), thanks.

> -Peff
Thanks,
Taylor
diff mbox series

Patch

diff --git a/midx.c b/midx.c
index dea78474a2..59097808a9 100644
--- a/midx.c
+++ b/midx.c
@@ -465,8 +465,7 @@  int cmp_idx_or_pack_name(const char *idx_or_pack_name,
 	return strcmp(idx_or_pack_name, idx_name);
 }
 
-int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
-		     uint32_t *pos)
+int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
 {
 	uint32_t first = 0, last = m->num_packs;
 
@@ -477,11 +476,8 @@  int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
 
 		current = m->pack_names[mid];
 		cmp = cmp_idx_or_pack_name(idx_or_pack_name, current);
-		if (!cmp) {
-			if (pos)
-				*pos = mid;
+		if (!cmp)
 			return 1;
-		}
 		if (cmp > 0) {
 			first = mid + 1;
 			continue;
@@ -492,11 +488,6 @@  int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
 	return 0;
 }
 
-int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
-{
-	return midx_locate_pack(m, idx_or_pack_name, NULL);
-}
-
 int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id)
 {
 	if (m->preferred_pack_idx == -1) {
diff --git a/midx.h b/midx.h
index 46c53d69ff..86af7dfc5e 100644
--- a/midx.h
+++ b/midx.h
@@ -102,8 +102,6 @@  struct object_id *nth_midxed_object_oid(struct object_id *oid,
 int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
 int midx_contains_pack(struct multi_pack_index *m,
 		       const char *idx_or_pack_name);
-int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
-		     uint32_t *pos);
 int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id);
 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);