diff options
author | Kevin Willford <kewillf@microsoft.com> | 2017-08-21 15:24:32 -0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-21 16:02:59 -0700 |
commit | ce012deb98650b5b7bba58d534fed27628e34234 (patch) | |
tree | 82c4ad3e177740cdcb0d941891b93ac5eaa917da /mergetools/examdiff | |
parent | read-cache: fix memory leak in do_write_index (diff) | |
download | tgif-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 'mergetools/examdiff')
0 files changed, 0 insertions, 0 deletions