From 4e1a7baa2e466afded9ff50b9a4539b24dbd3584 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 17 Jan 2010 15:43:13 +0700 Subject: [PATCH] rm: only refresh entries that we may touch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This gets rid of the whole tree cache refresh. Instead only path that we touch will get refreshed. We may still lstat() more than needed, but it'd be better playing safe. This potentially reduces a large number of lstat() on big trees. Take gentoo-x86 tree for example, which has roughly 80k files: Unmodified Git: $ time git rm --cached skel.ebuild rm 'skel.ebuild' real 0m1.441s user 0m0.821s sys 0m0.531s Modified Git: $ time ~/w/git/git rm --cached skel.ebuild rm 'skel.ebuild' real 0m0.941s user 0m0.828s sys 0m0.091s Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin-rm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-rm.c b/builtin-rm.c index 57975dbcf..f3772c84d 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -169,9 +169,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix) if (read_cache() < 0) die("index file corrupt"); - refresh_cache(REFRESH_QUIET); pathspec = get_pathspec(prefix, argv); + refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL); + seen = NULL; for (i = 0; pathspec[i] ; i++) /* nothing */; -- 2.30.2