git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] pack-object: trim memory usage a tiny bit

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 6, 2010, 17:00 UTC
Message-ID
<1281114057-5982-1-git-send-email-pclouds@gmail.com>

This shrinks struct object_entry from 88 bytes to 80 bytes on my 32 bit machine. So that would be 12M less on linux-2.6.git (1.6M objects)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Don't know if it's really worth a patch..
 builtin/pack-objects.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 0e81673..398c0bb 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -47,14 +47,14 @@ struct object_entry {
 	unsigned long delta_size;	/* delta data size (uncompressed) */
 	unsigned long z_delta_size;	/* delta data size (compressed) */
 	unsigned int hash;	/* name hint hash */
-	enum object_type type;
-	enum object_type in_pack_type;	/* could be delta */
+	enum object_type type:5;
+	enum object_type in_pack_type:5;	/* could be delta */
 	unsigned char in_pack_header_size;
-	unsigned char preferred_base; /* we do not pack this, but is available
-				       * to be used as the base object to delta
-				       * objects against.
-				       */
-	unsigned char no_try_delta;
+	unsigned char preferred_base:1; /* we do not pack this, but is available
+					 * to be used as the base object to delta
+					 * objects against.
+					 */
+	unsigned char no_try_delta:1;
 };
 
 /*
@@ -1001,6 +1001,7 @@ static void check_object(struct object_entry *entry)
 		unsigned int avail;
 		off_t ofs;
 		unsigned char *buf, c;
+		enum object_type in_pack_type;
 
 		buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);
 
@@ -1009,8 +1010,9 @@ static void check_object(struct object_entry *entry)
 		 * since non-delta representations could still be reused.
 		 */
 		used = unpack_object_header_buffer(buf, avail,
-						   &entry->in_pack_type,
+						   &in_pack_type,
 						   &entry->size);
+		entry->in_pack_type = in_pack_type;
 		if (used == 0)
 			goto give_up;
 
-- 
1.7.1.rc1.69.g24c2f7
Next: Sverre Rabbelier
Message 1 of 7 in “pack-object: trim memory usage a tiny bit”
  1. pack-object: trim memory usage a tiny bitNguyễn Thái Ngọc Duy, Aug 6, 2010
  2. Sverre RabbelierAug 6, 2010
  3. Nguyen Thai Ngoc DuyAug 7, 2010
  4. Sverre RabbelierAug 7, 2010
  5. Nguyen Thai Ngoc DuyAug 7, 2010
  6. Shawn O. PearceAug 7, 2010
  7. Nguyen Thai Ngoc DuyAug 7, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.