commit 60f2eee18fcaff9bd6983122f15e71afa79ab46e from: Stefan Sperling date: Sun Jul 08 15:18:45 2018 UTC undo previous; too much mixup in one data structure commit - d54f52f450beca49be8a5f8af3094bdbbd2355d6 commit + 60f2eee18fcaff9bd6983122f15e71afa79ab46e blob - a01adb668268cd8751b7e4ee306c93866af410ac blob + 4023b5de72d091b968bdf6942e5153a6055d06f2 --- lib/commit_graph.c +++ 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); blob - 4ce7735194c446f4ad4b165ff43e24182f14aaf8 blob + 7d98296142abd2f7a34aef5776b35c41a97a36d0 --- lib/got_lib_object_idset.h +++ 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 **, blob - 55fb1fc0f2b60c45b2b441119ec66c788dd8b88a blob + 2c7c696978afa9567d80dfffd1a651122ec6bad9 --- lib/object_idset.c +++ 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 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; blob - de7c434d04ee947428398ffe12ecc547fc1c0b78 blob + 9f2643e160d80e60579fdc434640f570194ec4ca --- lib/repository.c +++ lib/repository.c @@ -312,8 +312,7 @@ got_repo_open(struct got_repository **ret, const char 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 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 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;