Re: [PATCH 1/3] match_pathname: avoid calling strncmp if baselen is 0

2013-03-09 Thread Antoine Pelisse
 diff --git a/dir.c b/dir.c
 index 57394e4..669cf80 100644
 --- a/dir.c
 +++ b/dir.c
 @@ -663,7 +663,7 @@ int match_pathname(const char *pathname, int pathlen,
  */
 if (pathlen  baselen + 1 ||
 (baselen  pathname[baselen] != '/') ||
 -   strncmp_icase(pathname, base, baselen))
 +   (baselen  strncmp_icase(pathname, base, baselen)))

Shouldn't you factorize by baselen here ? For readability reasons, not
performance of course.

 return 0;

 namelen = baselen ? pathlen - baselen - 1 : pathlen;
--
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


[PATCH 1/3] match_pathname: avoid calling strncmp if baselen is 0

2013-03-08 Thread Nguyễn Thái Ngọc Duy
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:

before  after
user0m0.580s0m0.546s
user0m0.581s0m0.549s
user0m0.582s0m0.550s
user0m0.584s0m0.558s
user0m0.586s0m0.560s
user0m0.587s0m0.561s
user0m0.587s0m0.562s
user0m0.593s0m0.566s
user0m0.597s0m0.568s
user0m0.601s0m0.573s

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

diff --git a/dir.c b/dir.c
index 57394e4..669cf80 100644
--- a/dir.c
+++ b/dir.c
@@ -663,7 +663,7 @@ int match_pathname(const char *pathname, int pathlen,
 */
if (pathlen  baselen + 1 ||
(baselen  pathname[baselen] != '/') ||
-   strncmp_icase(pathname, base, baselen))
+   (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