Skip to content

Commit 216c405

Browse files
peffdscho
authored andcommitted
object-file: move empty_tree struct into find_cached_object()
The fake empty_tree struct is a static global, but the only code that looks at it is find_cached_object(). The struct itself is a little odd, with an invalid "oid" field that is handled specially by that function. Since it's really just an implementation detail, let's move it to a static within the function. That future-proofs against other code trying to use it and seeing the weird oid value. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ae2155 commit 216c405

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

object-file.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,13 @@ static struct cached_object {
325325
} *cached_objects;
326326
static int cached_object_nr, cached_object_alloc;
327327

328-
static struct cached_object empty_tree = {
329-
/* no oid needed; we'll look it up manually based on the_hash_algo */
330-
.type = OBJ_TREE,
331-
.buf = "",
332-
};
333-
334328
static struct cached_object *find_cached_object(const struct object_id *oid)
335329
{
330+
static struct cached_object empty_tree = {
331+
/* no oid needed; we'll look it up manually based on the_hash_algo */
332+
.type = OBJ_TREE,
333+
.buf = "",
334+
};
336335
int i;
337336
struct cached_object *co = cached_objects;
338337

0 commit comments

Comments
 (0)