aboutsummaryrefslogtreecommitdiff
path: root/builtin-update-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-08-09 13:42:50 -0700
committerJunio C Hamano <gitster@pobox.com>2007-08-10 11:44:23 -0700
commitaf3785dc5a76f4d5ddb8039e33c322e0e8b60e72 (patch)
treec02265433c45546fddd7b1205aba081c32743a2c /builtin-update-index.c
parent63c21c494fc91eda339d06b3a466c4241afffc81 (diff)
downloadgit-af3785dc5a76f4d5ddb8039e33c322e0e8b60e72.tar.gz
git-af3785dc5a76f4d5ddb8039e33c322e0e8b60e72.tar.xz
Optimize "diff --cached" performance.
The read_tree() function is called only from the call chain to run "git diff --cached" (this includes the internal call made by git-runstatus to run_diff_index()). The function vacates stage without any funky "merge" magic. The caller then goes and compares stage #1 entries from the tree with stage #0 entries from the original index. When adding the cache entries this way, it used the general purpose add_cache_entry(). This function looks for an existing entry to replace or if there is none to find where to insert the new entry, resolves D/F conflict and all the other things. For the purpose of reading entries into an empty stage, none of that processing is needed. We can instead append everything and then sort the result at the end. This commit changes read_tree() to first make sure that there is no existing cache entries at specified stage, and if that is the case, it runs add_cache_entry() with ADD_CACHE_JUST_APPEND flag (new), and then sort the resulting cache using qsort(). This new flag tells add_cache_entry() to omit all the checks such as "Does this path already exist? Does adding this path remove other existing entries because it turns a directory to a file?" and instead append the given cache entry straight at the end of the active cache. The caller of course is expected to sort the resulting cache at the end before using the result. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-update-index.c')
0 files changed, 0 insertions, 0 deletions