Like the previous patch, this cuts down the number of str*cmp calls in read_directory (which does _a lot_). Again sorted results on webkit.git: before after user 0m0.546s 0m0.519s user 0m0.549s 0m0.521s user 0m0.550s 0m0.523s user 0m0.558s 0m0.532s user 0m0.560s 0m0.534s user 0m0.561s 0m0.536s user 0m0.562s 0m0.537s user 0m0.566s 0m0.545s user 0m0.568s 0m0.546s user 0m0.573s 0m0.548s Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- dir.c | 16 ---------------- dir.h | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/dir.c b/dir.c index 669cf80..f58320d 100644 --- a/dir.c +++ b/dir.c @@ -21,22 +21,6 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, in int check_only, const struct path_simplify *simplify); static int get_dtype(struct dirent *de, const char *path, int len); -/* helper string functions with support for the ignore_case flag */ -int strcmp_icase(const char *a, const char *b) -{ - return ignore_case ? strcasecmp(a, b) : strcmp(a, b); -} - -int strncmp_icase(const char *a, const char *b, size_t count) -{ - return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count); -} - -int fnmatch_icase(const char *pattern, const char *string, int flags) -{ - return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0)); -} - inline int git_fnmatch(const char *pattern, const char *string, int flags, int prefix) { diff --git a/dir.h b/dir.h index c3eb4b5..560ade4 100644 --- a/dir.h +++ b/dir.h @@ -200,9 +200,21 @@ extern int remove_dir_recursively(struct strbuf *path, int flag); /* tries to remove the path with empty directories along it, ignores ENOENT */ extern int remove_path(const char *path); -extern int strcmp_icase(const char *a, const char *b); -extern int strncmp_icase(const char *a, const char *b, size_t count); -extern int fnmatch_icase(const char *pattern, const char *string, int flags); +/* helper string functions with support for the ignore_case flag */ +static inline int strcmp_icase(const char *a, const char *b) +{ + return ignore_case ? strcasecmp(a, b) : strcmp(a, b); +} + +static inline int strncmp_icase(const char *a, const char *b, size_t count) +{ + return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count); +} + +static inline int fnmatch_icase(const char *pattern, const char *string, int flags) +{ + return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0)); +} /* * The prefix part of pattern must not contains wildcards. -- 1.8.1.2.536.gf441e6d -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html