summaryrefslogtreecommitdiff
path: root/builtin-rm.c
diff options
context:
space:
mode:
authorKjetil Barvik <barvik@broadpark.no>2009-01-18 15:14:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-18 21:54:45 (GMT)
commit92604b466344b2157efc42ef3521dac22d7906a2 (patch)
tree7ceaea4b2a2f1a893e985cbfe4eb3179f5af427f /builtin-rm.c
parent7eb5bbdb645e04d746bc0edea102744f50a5e529 (diff)
downloadgit-92604b466344b2157efc42ef3521dac22d7906a2.zip
git-92604b466344b2157efc42ef3521dac22d7906a2.tar.gz
git-92604b466344b2157efc42ef3521dac22d7906a2.tar.bz2
lstat_cache(): more cache effective symlink/directory detection
Make the cache functionality more effective. Previously when A/B/C/D was in the cache and A/B/C/E/file.c was called for, there was no match at all from the cache. Now we use the fact that the paths "A", "A/B" and "A/B/C" are already tested, and we only need to do an lstat() call on "A/B/C/E". We only cache/store the last path regardless of its type. Since the cache functionality is always used with alphabetically sorted names (at least it seems so for me), there is no need to store both the last symlink-leading path and the last real-directory path. Note that if the cache is not called with (mostly) alphabetically sorted names, neither the old, nor this new one, would be very effective. Previously, when symlink A/B/C/S was cached/stored in the symlink- leading path, and A/B/C/file.c was called for, it was not easy to use the fact that we already knew that the paths "A", "A/B" and "A/B/C" are real directories. Avoid copying the first path components of the name 2 zillion times when we test new path components. Since we always cache/store the last path, we can copy each component as we test those directly into the cache. Previously we ended up doing a memcpy() for the full path/name right before each lstat() call, and when updating the cache for each time we have tested a new path component. We also use less memory, that is, PATH_MAX bytes less memory on the stack and PATH_MAX bytes less memory on the heap. Thanks to Junio C Hamano, Linus Torvalds and Rene Scharfe for valuable comments to this patch! Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-rm.c')
0 files changed, 0 insertions, 0 deletions