summaryrefslogtreecommitdiff
path: root/t/unit-tests/u-oid-array.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-01-09 03:49:07 -0500
committerJunio C Hamano <gitster@pobox.com>2025-01-09 12:24:25 -0800
commit8c53354658462aa6783022def86750ab0b79eb6f (patch)
tree24cbcb9d3cfc34310e8678f7a261a3e764ec665f /t/unit-tests/u-oid-array.c
parenta8dda1af6ab400d45b7524bc46b64e04d14fc912 (diff)
tree-diff: pass whole path string to path_appendnew()
When diffing trees, we'll have a strbuf "base" containing the slash-separted names of our parent trees, and a "path" string representing an entry name from the current tree. We pass these separately to path_appendnew(), which combines them to form a single path string in the combine_diff_path struct. Instead, let's append the path string to our base strbuf ourselves, pass in the result, and then roll it back with strbuf_setlen(). This lets us simplify path_appendnew() a bit, enabling further refactoring. And while it might seem like this causes extra wasted allocations, it does not in practice. We reuse the same strbuf for each tree entry, so we only have to allocate it to match the largest name. Plus, in a recursive diff we'll end up doing this same operation to extend the base for the next level of recursion. So we're really just incurring a small memcpy(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests/u-oid-array.c')
0 files changed, 0 insertions, 0 deletions