summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bdc37f5)
raw | patch | inline | side by side (parent: bdc37f5)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 20 Jan 2006 01:13:51 +0000 (17:13 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 22 Jan 2006 03:33:22 +0000 (19:33 -0800) |
The d_ino field is only used for performance reasons in
fsck-objects. On a typical filesystem, i-number tends to have a
strong correlation with where the actual bits sit on the disk
platter, and we sort the entries to allow us scan things that
ought to be close together together.
If the platform lacks support for it, it is not a big deal.
Just do not use d_ino for sorting, and scan them unsorted.
Signed-off-by: Junio C Hamano <junkio@cox.net>
fsck-objects. On a typical filesystem, i-number tends to have a
strong correlation with where the actual bits sit on the disk
platter, and we sort the entries to allow us scan things that
ought to be close together together.
If the platform lacks support for it, it is not a big deal.
Just do not use d_ino for sorting, and scan them unsorted.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile | patch | blob | history | |
fsck-objects.c | patch | blob | history |
diff --git a/Makefile b/Makefile
index b4741ff3035bd16b90ca571857d57ffc35b1c1aa..334fe4ec414d42b644f486da0253545f2e44c91b 100644 (file)
--- a/Makefile
+++ b/Makefile
# Define NO_EXPAT if you do not have expat installed. git-http-push is
# not built, and you cannot push using http:// and https:// transports.
#
+# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
+#
# Define NO_STRCASESTR if you don't have strcasestr.
#
# Define NO_SETENV if you don't have setenv in the C library.
ALL_CFLAGS += -D__EXTENSIONS__
endif
ifeq ($(uname_O),Cygwin)
+ NO_D_INO_IN_DIRENT = YesPlease
NO_STRCASESTR = YesPlease
NEEDS_LIBICONV = YesPlease
# There are conflicting reports about this.
LIBS += -lnsl
SIMPLE_LIB += -lnsl
endif
+ifdef NO_D_INO_IN_DIRENT
+ ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
+endif
ifdef NO_STRCASESTR
COMPAT_CFLAGS += -DNO_STRCASESTR
COMPAT_OBJS += compat/strcasestr.o
diff --git a/fsck-objects.c b/fsck-objects.c
index 90e638e573be005033cbf7faeff6ea8e97a1e758..9950be264501a5c99eafe7c2438b27b857ba6402 100644 (file)
--- a/fsck-objects.c
+++ b/fsck-objects.c
static int keep_cache_objects = 0;
static unsigned char head_sha1[20];
+#if NO_D_INO_IN_DIRENT
+#define SORT_DIRENT 0
+#define DIRENT_SORT_HINT(de) 0
+#else
+#define SORT_DIRENT 1
+#define DIRENT_SORT_HINT(de) ((de)->d_ino)
+#endif
static void objreport(struct object *obj, const char *severity,
const char *err, va_list params)
{
int i, nr = sha1_list.nr;
- qsort(sha1_list.entry, nr, sizeof(struct sha1_entry *), ino_compare);
+ if (SORT_DIRENT)
+ qsort(sha1_list.entry, nr,
+ sizeof(struct sha1_entry *), ino_compare);
for (i = 0; i < nr; i++) {
struct sha1_entry *entry = sha1_list.entry[i];
unsigned char *sha1 = entry->sha1;
memcpy(name+2, de->d_name, len+1);
if (get_sha1_hex(name, sha1) < 0)
break;
- add_sha1_list(sha1, de->d_ino);
+ add_sha1_list(sha1, DIRENT_SORT_HINT(de));
continue;
}
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);