undo previous; too much mixup in one data structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index a01adb6..4023b5d 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -100,15 +100,13 @@ alloc_graph(void)
if (graph == NULL)
return NULL;
- graph->node_ids = got_object_idset_alloc(
- GOT_OBJECT_IDSET_ITERATE_BY_OBJECT_ID);
+ graph->node_ids = got_object_idset_alloc();
if (graph->node_ids == NULL) {
free(graph);
return NULL;
}
- graph->open_branches = got_object_idset_alloc(
- GOT_OBJECT_IDSET_ITERATE_BY_OBJECT_ID);
+ graph->open_branches = got_object_idset_alloc();
if (graph->open_branches == NULL) {
got_object_idset_free(graph->node_ids);
free(graph);
diff --git a/lib/got_lib_object_idset.h b/lib/got_lib_object_idset.h
index 4ce7735..7d98296 100644
--- a/lib/got_lib_object_idset.h
+++ b/lib/got_lib_object_idset.h
@@ -16,13 +16,7 @@
struct got_object_idset;
-enum got_object_idset_iteration_order {
- GOT_OBJECT_IDSET_ITERATE_BY_OBJECT_ID,
- GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED,
-};
-
-struct got_object_idset *got_object_idset_alloc(
- enum got_object_idset_iteration_order);
+struct got_object_idset *got_object_idset_alloc(void);
void got_object_idset_free(struct got_object_idset *);
const struct got_error *got_object_idset_add(void **,
diff --git a/lib/object_idset.c b/lib/object_idset.c
index 55fb1fc..2c7c696 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -52,11 +52,10 @@ struct got_object_idset {
int nelem[0xff + 1];
int totelem;
#define GOT_OBJECT_IDSET_MAX_ELEM INT_MAX
- enum got_object_idset_iteration_order order;
};
struct got_object_idset *
-got_object_idset_alloc(enum got_object_idset_iteration_order order)
+got_object_idset_alloc(void)
{
struct got_object_idset *set;
int i;
@@ -65,7 +64,6 @@ got_object_idset_alloc(enum got_object_idset_iteration_order order)
if (set == NULL)
return NULL;
- set->order = order;
for (i = 0; i < nitems(set->entries); i++)
TAILQ_INIT(&set->entries[i]);
@@ -109,8 +107,7 @@ got_object_idset_add(void **existing_data,
memcpy(&new->id, id, sizeof(new->id));
new->data = data;
- if (TAILQ_EMPTY(&set->entries[i]) ||
- set->order == GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED) {
+ if (TAILQ_EMPTY(&set->entries[i])) {
TAILQ_INSERT_HEAD(&set->entries[i], new, entry);
set->nelem[i]++;
set->totelem++;
@@ -157,18 +154,12 @@ got_object_idset_add(void **existing_data,
void *
got_object_idset_get(struct got_object_idset *set, struct got_object_id *id)
{
- struct got_object_idset_element *entry, *tmp;
+ struct got_object_idset_element *entry;
uint8_t i = id->sha1[0];
- TAILQ_FOREACH_SAFE(entry, &set->entries[i], entry, tmp) {
- if (got_object_id_cmp(&entry->id, id) != 0)
- continue;
- if (set->order == GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED &&
- entry != TAILQ_FIRST(&set->entries[i])) {
- TAILQ_REMOVE(&set->entries[i], entry, entry);
- TAILQ_INSERT_HEAD(&set->entries[i], entry, entry);
- }
- return entry->data;
+ TAILQ_FOREACH(entry, &set->entries[i], entry) {
+ if (got_object_id_cmp(&entry->id, id) == 0)
+ return entry->data;
}
return NULL;
diff --git a/lib/repository.c b/lib/repository.c
index de7c434..9f2643e 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -312,8 +312,7 @@ got_repo_open(struct got_repository **ret, const char *path)
goto done;
}
- repo->objcache.set = got_object_idset_alloc(
- GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED);
+ repo->objcache.set = got_object_idset_alloc();
if (repo->objcache.set == NULL) {
err = got_error_from_errno();
goto done;
@@ -321,8 +320,7 @@ got_repo_open(struct got_repository **ret, const char *path)
repo->objcache.type = GOT_OBJECT_CACHE_TYPE_OBJ;
repo->objcache.size = GOT_OBJECT_CACHE_SIZE_OBJ;
- repo->treecache.set = got_object_idset_alloc(
- GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED);
+ repo->treecache.set = got_object_idset_alloc();
if (repo->treecache.set == NULL) {
err = got_error_from_errno();
goto done;
@@ -330,8 +328,7 @@ got_repo_open(struct got_repository **ret, const char *path)
repo->treecache.type = GOT_OBJECT_CACHE_TYPE_TREE;
repo->treecache.size = GOT_OBJECT_CACHE_SIZE_TREE;
- repo->commitcache.set = got_object_idset_alloc(
- GOT_OBJECT_IDSET_ITERATE_RECENTLY_USED);
+ repo->commitcache.set = got_object_idset_alloc();
if (repo->commitcache.set == NULL) {
err = got_error_from_errno();
goto done;