pack-objects: shrink struct object_entry
Turn some boolean fields into bitfields and use uint32_t for name hash. This shrinks the size of the structure from 128 bytes to 120 bytes. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Feb 4, 2013 at 15:21 UTC
63cdcfa40f5791dd233c574f633e56e4058e5f8e
1 file changed
+12
-11
builtin/pack-objects.c
+12
-11
@@ -38,17 +38,18 @@ struct object_entry {
38
void *delta_data; /* cached delta (uncompressed) */
39
unsigned long delta_size; /* delta data size (uncompressed) */
40
unsigned long z_delta_size; /* delta data size (compressed) */
41
- unsigned int hash; /* name hint hash */
41
enum object_type type;
42
enum object_type in_pack_type; /* could be delta */
43
+ uint32_t hash; /* name hint hash */
44
unsigned char in_pack_header_size;
45
- unsigned char preferred_base; /* we do not pack this, but is available
46
- * to be used as the base object to delta
47
- * objects against.
48
- */
49
- unsigned char no_try_delta;
50
- unsigned char tagged; /* near the very tip of refs */
51
- unsigned char filled; /* assigned write-order */
45
+ unsigned preferred_base:1; /*
46
+ * we do not pack this, but is available
47
+ * to be used as the base object to delta
48
+ * objects against.
49
+ */
50
+ unsigned no_try_delta:1;
51
+ unsigned tagged:1; /* near the very tip of refs */
52
+ unsigned filled:1; /* assigned write-order */
53
};
54
55
/*
@@ -859,9 +860,9 @@ static void rehash_objects(void)
860
}
861
}
862
862
-static unsigned name_hash(const char *name)
863
+static uint32_t name_hash(const char *name)
864
{
864
- unsigned c, hash = 0;
865
+ uint32_t c, hash = 0;
866
867
if (!name)
868
return 0;
@@ -908,7 +909,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
909
struct packed_git *p, *found_pack = NULL;
910
off_t found_offset = 0;
911
int ix;
911
- unsigned hash = name_hash(name);
912
+ uint32_t hash = name_hash(name);
913
914
ix = nr_objects ? locate_object_entry_hash(sha1) : -1;
915
if (ix >= 0) {