From: Junio C Hamano Date: Sat, 09 Jan 2010 08:07:48 GMT Subject: Re: [PATCH] ls-files: fix overeager pathspec optimization Message-ID: <7vfx6f3dm3.fsf@alter.siamese.dyndns.org> In-Reply-To: <7veilzaguf.fsf@alter.siamese.dyndns.org> Junio C Hamano writes: > Linus Torvalds writes: > >> I'd have to see both patches to be able to tell. I do admit that while I >> acked your patch, it sure ain't _pretty_ to do that special odd >> "has_leading_ignored_dir()" thing. > > Revised patch (v4) series is coming shortly. Having sent these patches, I am wondering if the simplest fix might be this one-liner. diff --git a/dir.c b/dir.c index d0999ba..7fba335 100644 --- a/dir.c +++ b/dir.c @@ -788,3 +788,3 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const char simplify = create_simplify(pathspec); - read_directory_recursive(dir, path, len, 0, simplify); + read_directory_recursive(dir, "", 0, 0, simplify); free_simplify(simplify); What my series does is to keep all the "depending on dir->flags and what excluded() says for path, decide to recurse, add it to dir->ignored[], etc." logic and optimize only the readdir() loop, pretending as if it returned only the entry on the "common prefix" path and nothing else, as we know all other paths will be skipped by either simplified away or filtered by in_pathspec() check. If the directories we are reading are not humongous, maybe using this much simpler patch might be preferrable (although it is completely untested).