diff options
author | Marius Storm-Olsen <marius@trolltech.com> | 2009-05-31 18:15:22 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-06-01 00:25:54 -0700 |
commit | e16c60d9f98c66fd2c9bba64562b3439970c13f8 (patch) | |
tree | ac682110cc4fc94da135be7e5f3033119e3e496e /compat/mingw.h | |
parent | connect.c: Support PuTTY plink and TortoisePlink as SSH on Windows (diff) | |
download | tgif-e16c60d9f98c66fd2c9bba64562b3439970c13f8.tar.xz |
MinGW readdir reimplementation to support d_type
The original readdir implementation was fast, but didn't
support the d_type. This means that git would do additional
lstats for each entry, to figure out if the entry was a
directory or not. This unneedingly slowed down many
operations, since Windows API provides this information
directly when walking the directories.
By running this implementation on Moe's repo structure:
mkdir bummer && cd bummer; for ((i=0;i<100;i++)); do
mkdir $i && pushd $i;
for ((j=0;j<1000;j++)); do echo "$j" >$j; done;
popd;
done
We see the following speedups:
git add .
-------------------
old: 00:00:23(.087)
new: 00:00:21(.512) 1.07x
git status
-------------------
old: 00:00:03(.306)
new: 00:00:01(.684) 1.96x
git clean -dxf
-------------------
old: 00:00:01(.918)
new: 00:00:00(.295) 6.50x
Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/mingw.h')
-rw-r--r-- | compat/mingw.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h index 4c50f5b1bc..4f7ba4c13f 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -235,3 +235,32 @@ int main(int argc, const char **argv) \ return mingw_main(argc, argv); \ } \ static int mingw_main(c,v) + +#ifndef NO_MINGW_REPLACE_READDIR +/* + * A replacement of readdir, to ensure that it reads the file type at + * the same time. This avoid extra unneeded lstats in git on MinGW + */ +#undef DT_UNKNOWN +#undef DT_DIR +#undef DT_REG +#undef DT_LNK +#define DT_UNKNOWN 0 +#define DT_DIR 1 +#define DT_REG 2 +#define DT_LNK 3 + +struct mingw_dirent +{ + long d_ino; /* Always zero. */ + union { + unsigned short d_reclen; /* Always zero. */ + unsigned char d_type; /* Reimplementation adds this */ + }; + unsigned short d_namlen; /* Length of name in d_name. */ + char d_name[FILENAME_MAX]; /* File name. */ +}; +#define dirent mingw_dirent +#define readdir(x) mingw_readdir(x) +struct dirent *mingw_readdir(DIR *dir); +#endif // !NO_MINGW_REPLACE_READDIR |