Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee42bb0

Browse files
committed
tree: make path len uint16_t and avoid holes
This reduces the size of the struct from 32 to 26 bytes, and leaves a single padding byte at the end of the struct (which comes from the zero-length array).
1 parent 2580077 commit ee42bb0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static git_tree_entry *alloc_entry(const char *filename)
125125

126126
struct tree_key_search {
127127
const char *filename;
128-
size_t filename_len;
128+
uint16_t filename_len;
129129
};
130130

131131
static int homing_search_cmp(const void *key, const void *array_member)

src/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
struct git_tree_entry {
1818
uint16_t attr;
19+
uint16_t filename_len;
1920
git_oid oid;
2021
bool pooled;
21-
size_t filename_len;
2222
char filename[GIT_FLEX_ARRAY];
2323
};
2424

0 commit comments

Comments
 (0)