From: Junio C Hamano Date: Sun, 30 Mar 2008 16:25:52 +0000 (-0700) Subject: write_index(): optimize ce_smudge_racily_clean_entry() calls with CE_UPTODATE X-Git-Tag: v1.5.6-rc0~91^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e06c43c7959042e5612984b8193700f32f12b2be;p=git.git write_index(): optimize ce_smudge_racily_clean_entry() calls with CE_UPTODATE When writing the index out, we need to check the work tree again to see if an entry whose timestamp indicates that it could be "racily clean", in order to smudge it if it is stat-clean but with modified contents. However, we can skip this step for entries marked with CE_UPTODATE, which are known to be the really clean (i.e. the one we already have checked when we prepared the index). This will reduce lstat(2) calls necessary in git-status. Signed-off-by: Junio C Hamano --- diff --git a/read-cache.c b/read-cache.c index a92b25b59..c3692f41a 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1370,7 +1370,7 @@ int write_index(const struct index_state *istate, int newfd) struct cache_entry *ce = cache[i]; if (ce->ce_flags & CE_REMOVE) continue; - if (is_racy_timestamp(istate, ce)) + if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce)) ce_smudge_racily_clean_entry(ce); if (ce_write_entry(&c, newfd, ce) < 0) return -1;