aboutsummaryrefslogtreecommitdiff
path: root/pack-redundant.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-16 21:32:44 -0800
committerJunio C Hamano <junkio@cox.net>2005-11-16 21:32:44 -0800
commit27dedf0c3b78d1072fb5449149421284f9e5297b (patch)
tree80da2302f50bb1f396611a4a54a6da52a4592bd0 /pack-redundant.c
parent60d64db4614b1007ca37c228923ec1964d5ad394 (diff)
downloadgit-27dedf0c3b78d1072fb5449149421284f9e5297b.tar.gz
git-27dedf0c3b78d1072fb5449149421284f9e5297b.tar.xz
GIT 0.99.9j aka 1.0rc3v1.0rc3v0.99.9j
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'pack-redundant.c')
-rw-r--r--pack-redundant.c47
1 files changed, 15 insertions, 32 deletions
diff --git a/pack-redundant.c b/pack-redundant.c
index 28b82ee65..fcb36ff90 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -127,38 +127,6 @@ inline struct llist_item * llist_insert_sorted_unique(struct llist *list,
return llist_insert_back(list, sha1);
}
-/* computes A\B */
-void llist_sorted_difference_inplace(struct llist *A,
- struct llist *B)
-{
- struct llist_item *prev, *a, *b, *x;
-
- prev = a = A->front;
- b = B->front;
-
- while (a != NULL && b != NULL) {
- int cmp = memcmp(a->sha1, b->sha1, 20);
- if (!cmp) {
- x = a;
- if (a == A->front)
- A->front = a->next;
- a = prev->next = a->next;
-
- if (a == NULL) /* end of list */
- A->back = prev;
- A->size--;
- free(x);
- b = b->next;
- } else
- if (cmp > 0)
- b = b->next;
- else {
- prev = a;
- a = a->next;
- }
- }
-}
-
/* returns a pointer to an item in front of sha1 */
inline struct llist_item * llist_sorted_remove(struct llist *list, char *sha1,
struct llist_item *hint)
@@ -194,6 +162,21 @@ redo_from_start:
return prev;
}
+/* computes A\B */
+void llist_sorted_difference_inplace(struct llist *A,
+ struct llist *B)
+{
+ struct llist_item *hint, *b;
+
+ hint = NULL;
+ b = B->front;
+
+ while (b) {
+ hint = llist_sorted_remove(A, b->sha1, hint);
+ b = b->next;
+ }
+}
+
inline struct pack_list * pack_list_insert(struct pack_list **pl,
struct pack_list *entry)
{