Commit f831532b96ca120d766ce7c8ee00fdd5a0d7b415

Stefan Sperling 2018-07-23T11:22:21

remove unused got_object_idset_remove_random()

diff --git a/lib/got_lib_object_idset.h b/lib/got_lib_object_idset.h
index 7d98296..a64e2b7 100644
--- a/lib/got_lib_object_idset.h
+++ b/lib/got_lib_object_idset.h
@@ -24,8 +24,6 @@ const struct got_error *got_object_idset_add(void **,
 void *got_object_idset_get(struct got_object_idset *, struct got_object_id *);
 const struct got_error *got_object_idset_remove(void **,
     struct got_object_idset *, struct got_object_id *);
-const struct got_error *got_object_idset_remove_random(void **,
-    struct got_object_idset *);
 int got_object_idset_contains(struct got_object_idset *,
     struct got_object_id *);
 void got_object_idset_for_each(struct got_object_idset *,
diff --git a/lib/object_idset.c b/lib/object_idset.c
index 5603540..75d0573 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -193,49 +193,6 @@ got_object_idset_remove(void **data, struct got_object_idset *set,
 	return got_error(GOT_ERR_NO_OBJ);
 }
 
-const struct got_error *
-got_object_idset_remove_random(void **data, struct got_object_idset *set)
-{
-	struct got_object_idset_element *entry, *tmp;
-	int i, n, totelem;
-
-	if (data)
-		*data = NULL;
-
-	if (set->totelem == 0)
-		return got_error(GOT_ERR_NO_OBJ);
-
-	/* Pick a random element index across all lists. */
-	if (set->totelem == 1)
-		n = 0;
-	else
-		n = arc4random_uniform(set->totelem);
-
-	totelem = 0;
-	for (i = 0; i < nitems(set->entries); i++) {
-		/* Skip lists which don't contain the element we picked. */
-		totelem += set->nelem[i];
-		if (totelem == 0 || n > totelem - 1) {
-			n -= set->nelem[i];
-			continue;
-		}
-		TAILQ_FOREACH_SAFE(entry, &set->entries[i], entry, tmp) {
-			if (n == 0) {
-				TAILQ_REMOVE(&set->entries[i], entry, entry);
-				if (data)
-					*data = entry->data;
-				free(entry);
-				set->nelem[i]--;
-				set->totelem--;
-				return NULL;
-			}
-			n--;
-		}
-	}
-
-	return got_error(GOT_ERR_NO_OBJ);
-}
-
 int
 got_object_idset_contains(struct got_object_idset *set,
     struct got_object_id *id)