summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Kevin Willford <kewillf@microsoft.com>2017-08-21 15:24:32 -0600
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-08-21 16:02:59 -0700
commitce012deb98650b5b7bba58d534fed27628e34234 (patch)
tree82c4ad3e177740cdcb0d941891b93ac5eaa917da /t
parentread-cache: fix memory leak in do_write_index (diff)
downloadtgif-ce012deb98650b5b7bba58d534fed27628e34234.tar.xz
read-cache: avoid allocating every ondisk entry when writing
When writing the index for each entry an ondisk struct will be allocated and freed in ce_write_entry. We can do better by using a ondisk struct on the stack for each entry. This is accomplished by using a stack ondisk_cache_entry_extended outside looping through the entries in do_write_index. Only the fixed fields of this struct are used when writing and depending on whether it is extended or not the flags2 field will be written. The name field is not used and instead the cache_entry name field is used directly when writing out the name. Because ce_write is using a buffer and memcpy to fill the buffer before flushing to disk, we don't have to worry about doing multiple ce_write calls. Running the p0007-write-cache.sh tests would save anywhere between 3-7% when the index had over a million entries with no performance degradation on small repos. Signed-off-by: Kevin Willford <kewillf@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
0 files changed, 0 insertions, 0 deletions