mirror of
https://github.com/git/git
synced 2024-11-05 01:58:18 +00:00
oidset: refactor oidset_insert_from_set()
In a following commit, we will need to add all the oids from a set into another set. In "list-objects-filter.c", there is already a static function called add_all() to do that. Let's rename this function oidset_insert_from_set() and move it into oidset.{c,h} to make it generally available. While at it, let's remove a useless `!= NULL`. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3ff56af99b
commit
eaf07b7d15
3 changed files with 17 additions and 10 deletions
|
@ -711,15 +711,6 @@ static void filter_combine__free(void *filter_data)
|
||||||
free(d);
|
free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_all(struct oidset *dest, struct oidset *src) {
|
|
||||||
struct oidset_iter iter;
|
|
||||||
struct object_id *src_oid;
|
|
||||||
|
|
||||||
oidset_iter_init(src, &iter);
|
|
||||||
while ((src_oid = oidset_iter_next(&iter)) != NULL)
|
|
||||||
oidset_insert(dest, src_oid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void filter_combine__finalize_omits(
|
static void filter_combine__finalize_omits(
|
||||||
struct oidset *omits,
|
struct oidset *omits,
|
||||||
void *filter_data)
|
void *filter_data)
|
||||||
|
@ -728,7 +719,7 @@ static void filter_combine__finalize_omits(
|
||||||
size_t sub;
|
size_t sub;
|
||||||
|
|
||||||
for (sub = 0; sub < d->nr; sub++) {
|
for (sub = 0; sub < d->nr; sub++) {
|
||||||
add_all(omits, &d->sub[sub].omits);
|
oidset_insert_from_set(omits, &d->sub[sub].omits);
|
||||||
oidset_clear(&d->sub[sub].omits);
|
oidset_clear(&d->sub[sub].omits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
oidset.c
10
oidset.c
|
@ -23,6 +23,16 @@ int oidset_insert(struct oidset *set, const struct object_id *oid)
|
||||||
return !added;
|
return !added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void oidset_insert_from_set(struct oidset *dest, struct oidset *src)
|
||||||
|
{
|
||||||
|
struct oidset_iter iter;
|
||||||
|
struct object_id *src_oid;
|
||||||
|
|
||||||
|
oidset_iter_init(src, &iter);
|
||||||
|
while ((src_oid = oidset_iter_next(&iter)))
|
||||||
|
oidset_insert(dest, src_oid);
|
||||||
|
}
|
||||||
|
|
||||||
int oidset_remove(struct oidset *set, const struct object_id *oid)
|
int oidset_remove(struct oidset *set, const struct object_id *oid)
|
||||||
{
|
{
|
||||||
khiter_t pos = kh_get_oid_set(&set->set, *oid);
|
khiter_t pos = kh_get_oid_set(&set->set, *oid);
|
||||||
|
|
6
oidset.h
6
oidset.h
|
@ -47,6 +47,12 @@ int oidset_contains(const struct oidset *set, const struct object_id *oid);
|
||||||
*/
|
*/
|
||||||
int oidset_insert(struct oidset *set, const struct object_id *oid);
|
int oidset_insert(struct oidset *set, const struct object_id *oid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert all the oids that are in set 'src' into set 'dest'; a copy
|
||||||
|
* is made of each oid inserted into set 'dest'.
|
||||||
|
*/
|
||||||
|
void oidset_insert_from_set(struct oidset *dest, struct oidset *src);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the oid from the set.
|
* Remove the oid from the set.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue