This reduces "git status" user time by a little bit. This is the
sorted results of 10 consecutive runs of "git ls-files
--exclude-standard -o" on webkit.git, compiled with gcc -O2:

treat_leading_path:   0.000  0.000
read_directory:       4.102  3.674
+treat_one_path:      2.843  2.427
++is_excluded:        2.632  2.221
+++prep_exclude:      0.225  0.224
+++matching:          2.054  1.650
++dir_exist:          0.035  0.035
++index_name_exists:  0.292  0.288
lazy_init_name_hash:  0.258  0.257
+simplify_away:       0.085  0.085
+dir_add_name:        0.446  0.441

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dir.c b/dir.c
index 69c045b..32a3adb 100644
--- a/dir.c
+++ b/dir.c
@@ -688,8 +688,8 @@ int match_pathname(const char *pathname, int pathlen,
         * may not end with a trailing slash though.
         */
        if (pathlen < baselen + 1 ||
-           (baselen && pathname[baselen] != '/') ||
-           strncmp_icase(pathname, base, baselen))
+           (baselen && (pathname[baselen] != '/' ||
+                        strncmp_icase(pathname, base, baselen))))
                return 0;
 
        namelen = baselen ? pathlen - baselen - 1 : pathlen;
-- 
1.8.1.2.536.gf441e6d

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to