2005-04-18 20:39:48 +02:00
|
|
|
#ifndef OBJECT_H
|
|
|
|
#define OBJECT_H
|
|
|
|
|
|
|
|
struct object_list {
|
|
|
|
struct object *item;
|
|
|
|
struct object_list *next;
|
2005-06-27 00:26:05 +02:00
|
|
|
const char *name;
|
2005-04-18 20:39:48 +02:00
|
|
|
};
|
|
|
|
|
2005-11-17 06:32:44 +01:00
|
|
|
struct object_refs {
|
|
|
|
unsigned count;
|
2006-06-18 20:45:02 +02:00
|
|
|
struct object *base;
|
2006-01-07 10:33:54 +01:00
|
|
|
struct object *ref[FLEX_ARRAY]; /* more */
|
2005-11-17 06:32:44 +01:00
|
|
|
};
|
|
|
|
|
Shrink "struct object" a bit
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.
In addition, we merge the bitfields and the "flags" field, which
incidentally should also remove a useless 4-byte padding from the object
when in 64-bit mode.
Now, our "struct object" is still too damn large, but it's now less
obviously bloated, and of the remaining fields, only the "util" (which is
not used by most things) is clearly something that should be eventually
discarded.
This shrinks the "git-rev-list --all" memory use by about 2.5% on the
kernel archive (and, perhaps more importantly, on the larger mozilla
archive). That may not sound like much, but I suspect it's more on a
64-bit platform.
There are other remaining inefficiencies (the parent lists, for example,
probably have horrible malloc overhead), but this was pretty obvious.
Most of the patch is just changing the comparison of the "type" pointer
from one of the constant string pointers to the appropriate new TYPE_xxx
small integer constant.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-15 01:45:13 +02:00
|
|
|
#define TYPE_BITS 3
|
|
|
|
#define FLAG_BITS 27
|
|
|
|
|
|
|
|
#define TYPE_NONE 0
|
|
|
|
#define TYPE_BLOB 1
|
|
|
|
#define TYPE_TREE 2
|
|
|
|
#define TYPE_COMMIT 3
|
|
|
|
#define TYPE_TAG 4
|
|
|
|
#define TYPE_BAD 5
|
|
|
|
|
2005-04-18 20:39:48 +02:00
|
|
|
struct object {
|
|
|
|
unsigned parsed : 1;
|
|
|
|
unsigned used : 1;
|
Shrink "struct object" a bit
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.
In addition, we merge the bitfields and the "flags" field, which
incidentally should also remove a useless 4-byte padding from the object
when in 64-bit mode.
Now, our "struct object" is still too damn large, but it's now less
obviously bloated, and of the remaining fields, only the "util" (which is
not used by most things) is clearly something that should be eventually
discarded.
This shrinks the "git-rev-list --all" memory use by about 2.5% on the
kernel archive (and, perhaps more importantly, on the larger mozilla
archive). That may not sound like much, but I suspect it's more on a
64-bit platform.
There are other remaining inefficiencies (the parent lists, for example,
probably have horrible malloc overhead), but this was pretty obvious.
Most of the patch is just changing the comparison of the "type" pointer
from one of the constant string pointers to the appropriate new TYPE_xxx
small integer constant.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-15 01:45:13 +02:00
|
|
|
unsigned type : TYPE_BITS;
|
|
|
|
unsigned flags : FLAG_BITS;
|
2005-04-18 20:39:48 +02:00
|
|
|
unsigned char sha1[20];
|
|
|
|
};
|
|
|
|
|
2005-09-16 23:55:33 +02:00
|
|
|
extern int track_object_refs;
|
2006-02-12 02:57:57 +01:00
|
|
|
extern int obj_allocs;
|
2005-05-11 00:58:16 +02:00
|
|
|
extern struct object **objs;
|
Shrink "struct object" a bit
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.
In addition, we merge the bitfields and the "flags" field, which
incidentally should also remove a useless 4-byte padding from the object
when in 64-bit mode.
Now, our "struct object" is still too damn large, but it's now less
obviously bloated, and of the remaining fields, only the "util" (which is
not used by most things) is clearly something that should be eventually
discarded.
This shrinks the "git-rev-list --all" memory use by about 2.5% on the
kernel archive (and, perhaps more importantly, on the larger mozilla
archive). That may not sound like much, but I suspect it's more on a
64-bit platform.
There are other remaining inefficiencies (the parent lists, for example,
probably have horrible malloc overhead), but this was pretty obvious.
Most of the patch is just changing the comparison of the "type" pointer
from one of the constant string pointers to the appropriate new TYPE_xxx
small integer constant.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-15 01:45:13 +02:00
|
|
|
extern const char *type_names[];
|
|
|
|
|
|
|
|
static inline const char *typename(unsigned int type)
|
|
|
|
{
|
|
|
|
return type_names[type > TYPE_TAG ? TYPE_BAD : type];
|
|
|
|
}
|
2005-04-18 20:39:48 +02:00
|
|
|
|
2006-06-18 20:45:02 +02:00
|
|
|
extern struct object_refs *lookup_object_refs(struct object *);
|
|
|
|
|
2005-06-22 02:35:10 +02:00
|
|
|
/** Internal only **/
|
2005-06-03 17:05:39 +02:00
|
|
|
struct object *lookup_object(const unsigned char *sha1);
|
2005-04-18 20:39:48 +02:00
|
|
|
|
2005-06-22 02:35:10 +02:00
|
|
|
/** Returns the object, having looked it up as being the given type. **/
|
|
|
|
struct object *lookup_object_type(const unsigned char *sha1, const char *type);
|
|
|
|
|
2005-06-03 17:05:39 +02:00
|
|
|
void created_object(const unsigned char *sha1, struct object *obj);
|
2005-04-18 20:39:48 +02:00
|
|
|
|
2005-04-28 16:46:33 +02:00
|
|
|
/** Returns the object, having parsed it to find out what it is. **/
|
2005-06-03 17:05:39 +02:00
|
|
|
struct object *parse_object(const unsigned char *sha1);
|
2005-04-28 16:46:33 +02:00
|
|
|
|
2005-08-03 01:45:48 +02:00
|
|
|
/** Returns the object, with potentially excess memory allocated. **/
|
|
|
|
struct object *lookup_unknown_object(const unsigned char *sha1);
|
|
|
|
|
2005-11-17 06:32:44 +01:00
|
|
|
struct object_refs *alloc_object_refs(unsigned count);
|
|
|
|
void set_object_refs(struct object *obj, struct object_refs *refs);
|
2005-04-18 20:39:48 +02:00
|
|
|
|
|
|
|
void mark_reachable(struct object *obj, unsigned int mask);
|
|
|
|
|
2005-08-03 01:45:48 +02:00
|
|
|
struct object_list *object_list_insert(struct object *item,
|
|
|
|
struct object_list **list_p);
|
|
|
|
|
2005-09-05 08:04:18 +02:00
|
|
|
void object_list_append(struct object *item,
|
|
|
|
struct object_list **list_p);
|
|
|
|
|
2005-08-03 01:45:48 +02:00
|
|
|
unsigned object_list_length(struct object_list *list);
|
|
|
|
|
|
|
|
int object_list_contains(struct object_list *list, struct object *obj);
|
|
|
|
|
2005-04-18 20:39:48 +02:00
|
|
|
#endif /* OBJECT_H */
|