Re: Shrink "struct object" a bit
- From
- Philip Pokorny <ppokorny@mindspring.com>
- Date
- Jun 17, 2006, 15:36 UTC
- Message-ID
- <44942176.1070107@mindspring.com>
- In-Reply-To
- <Pine.LNX.4.64.0606141630570.5498@g5.osdl.org>
Linus Torvalds wrote:
Show 16 quoted lines
>This shrinks "struct object" by a small amount, by getting rid of the
>"struct type *" pointer and replacing it with a 3-bit bitfield instead.
>
>@@ -179,9 +179,7 @@ static int loop(void)
> */
> if (! (obj->flags & TO_SCAN)) {
> if (fetch(obj->sha1)) {
>- report_missing(obj->type
>- ? obj->type
>- : "object", obj->sha1);
>+ report_missing(typename(obj->type), obj->sha1);
> return -1;
> }
> }
>
>Show 14 quoted lines
>diff --git a/object.c b/object.c
>index 9adc874..0f70890 100644
>--- a/object.c
>+++ b/object.c
>@@ -9,6 +9,10 @@ struct object **objs;
> static int nr_objs;
> int obj_allocs;
>
>+const char *type_names[] = {
>+ "none", "blob", "tree", "commit", "bad"
>+};
>+
>
>A minor thing, but doesn't this mean the "report_missing" message would change from:
> Cannot obtain needed object ab12cdef1234567890abcd > while processing commit fedcbadeadbeefdeadbe
to
> Cannot obtain needed none ab12cdef1234567890abcd > while processing commit fedcbadeadbeefdeadbe
in some cases? I'm not sure that it's possible for the type value to be unspecified at this point in the code, but it seemed like the output from report_missing would be confusing if this ever happened.
:v)