diff options
-rw-r--r-- | alloc.c | 16 | ||||
-rw-r--r-- | alloc.h | 2 | ||||
-rw-r--r-- | blob.c | 2 | ||||
-rw-r--r-- | builtin/commit-graph.c | 2 | ||||
-rw-r--r-- | builtin/fsck.c | 2 | ||||
-rw-r--r-- | commit.c | 4 | ||||
-rw-r--r-- | object.c | 4 | ||||
-rw-r--r-- | object.h | 3 | ||||
-rw-r--r-- | refs.c | 2 | ||||
-rw-r--r-- | t/helper/test-reach.c | 2 | ||||
-rw-r--r-- | tag.c | 2 | ||||
-rw-r--r-- | tree.c | 2 |
12 files changed, 24 insertions, 19 deletions
@@ -99,15 +99,21 @@ void *alloc_object_node(struct repository *r) return obj; } -static unsigned int alloc_commit_index(struct repository *r) +/* + * The returned count is to be used as an index into commit slabs, + * that are *NOT* maintained per repository, and that is why a single + * global counter is used. + */ +static unsigned int alloc_commit_index(void) { - return r->parsed_objects->commit_count++; + static unsigned int parsed_commits_count; + return parsed_commits_count++; } -void init_commit_node(struct repository *r, struct commit *c) +void init_commit_node(struct commit *c) { c->object.type = OBJ_COMMIT; - c->index = alloc_commit_index(r); + c->index = alloc_commit_index(); c->graph_pos = COMMIT_NOT_FROM_GRAPH; c->generation = GENERATION_NUMBER_INFINITY; } @@ -115,7 +121,7 @@ void init_commit_node(struct repository *r, struct commit *c) void *alloc_commit_node(struct repository *r) { struct commit *c = alloc_node(r->parsed_objects->commit_state, sizeof(struct commit)); - init_commit_node(r, c); + init_commit_node(c); return c; } @@ -9,7 +9,7 @@ struct repository; void *alloc_blob_node(struct repository *r); void *alloc_tree_node(struct repository *r); -void init_commit_node(struct repository *r, struct commit *c); +void init_commit_node(struct commit *c); void *alloc_commit_node(struct repository *r); void *alloc_tag_node(struct repository *r); void *alloc_object_node(struct repository *r); @@ -10,7 +10,7 @@ struct blob *lookup_blob(struct repository *r, const struct object_id *oid) struct object *obj = lookup_object(r, oid); if (!obj) return create_object(r, oid, alloc_blob_node(r)); - return object_as_type(r, obj, OBJ_BLOB, 0); + return object_as_type(obj, OBJ_BLOB, 0); } int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 75455da138..f6797e2a9f 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -154,7 +154,7 @@ static int read_one_commit(struct oidset *commits, struct progress *progress, NULL, 0); if (!result) return error(_("invalid object: %s"), hash); - else if (object_as_type(the_repository, result, OBJ_COMMIT, 1)) + else if (object_as_type(result, OBJ_COMMIT, 1)) oidset_insert(commits, &result->oid); display_progress(progress, oidset_size(commits)); diff --git a/builtin/fsck.c b/builtin/fsck.c index f02cbdb439..b2cef01389 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -241,7 +241,7 @@ static void mark_unreachable_referents(const struct object_id *oid) enum object_type type = oid_object_info(the_repository, &obj->oid, NULL); if (type > 0) - object_as_type(the_repository, obj, type, 0); + object_as_type(obj, type, 0); } options.walk = mark_used; @@ -37,7 +37,7 @@ struct commit *lookup_commit_reference_gently(struct repository *r, if (!obj) return NULL; - return object_as_type(r, obj, OBJ_COMMIT, quiet); + return object_as_type(obj, OBJ_COMMIT, quiet); } struct commit *lookup_commit_reference(struct repository *r, const struct object_id *oid) @@ -62,7 +62,7 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid) struct object *obj = lookup_object(r, oid); if (!obj) return create_object(r, oid, alloc_commit_node(r)); - return object_as_type(r, obj, OBJ_COMMIT, 0); + return object_as_type(obj, OBJ_COMMIT, 0); } struct commit *lookup_commit_reference_by_name(const char *name) @@ -157,13 +157,13 @@ void *create_object(struct repository *r, const struct object_id *oid, void *o) return obj; } -void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet) +void *object_as_type(struct object *obj, enum object_type type, int quiet) { if (obj->type == type) return obj; else if (obj->type == OBJ_NONE) { if (type == OBJ_COMMIT) - init_commit_node(r, (struct commit *) obj); + init_commit_node((struct commit *) obj); else obj->type = type; return obj; @@ -15,7 +15,6 @@ struct parsed_object_pool { struct alloc_state *commit_state; struct alloc_state *tag_state; struct alloc_state *object_state; - unsigned commit_count; /* parent substitutions from .git/info/grafts and .git/shallow */ struct commit_graft **grafts; @@ -121,7 +120,7 @@ struct object *lookup_object(struct repository *r, const struct object_id *oid); void *create_object(struct repository *r, const struct object_id *oid, void *obj); -void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet); +void *object_as_type(struct object *obj, enum object_type type, int quiet); /* * Returns the object, having parsed it to find out what it is. @@ -339,7 +339,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid if (o->type == OBJ_NONE) { int type = oid_object_info(the_repository, name, NULL); - if (type < 0 || !object_as_type(the_repository, o, type, 0)) + if (type < 0 || !object_as_type(o, type, 0)) return PEEL_INVALID; } diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index a0272178b7..ccf837cb33 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -67,7 +67,7 @@ int cmd__reach(int ac, const char **av) die("failed to load commit for input %s resulting in oid %s\n", buf.buf, oid_to_hex(&oid)); - c = object_as_type(r, peeled, OBJ_COMMIT, 0); + c = object_as_type(peeled, OBJ_COMMIT, 0); if (!c) die("failed to load commit for input %s resulting in oid %s\n", @@ -103,7 +103,7 @@ struct tag *lookup_tag(struct repository *r, const struct object_id *oid) struct object *obj = lookup_object(r, oid); if (!obj) return create_object(r, oid, alloc_tag_node(r)); - return object_as_type(r, obj, OBJ_TAG, 0); + return object_as_type(obj, OBJ_TAG, 0); } static timestamp_t parse_tag_date(const char *buf, const char *tail) @@ -200,7 +200,7 @@ struct tree *lookup_tree(struct repository *r, const struct object_id *oid) struct object *obj = lookup_object(r, oid); if (!obj) return create_object(r, oid, alloc_tree_node(r)); - return object_as_type(r, obj, OBJ_TREE, 0); + return object_as_type(obj, OBJ_TREE, 0); } int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size) |