summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache.h3
-rw-r--r--preload-index.c8
-rw-r--r--read-cache.c6
3 files changed, 13 insertions, 4 deletions
diff --git a/cache.h b/cache.h
index f7fabdd..883099d 100644
--- a/cache.h
+++ b/cache.h
@@ -659,6 +659,9 @@ extern int daemonize(void);
/* Initialize and use the cache information */
struct lock_file;
extern int read_index(struct index_state *);
+extern void preload_index(struct index_state *index,
+ const struct pathspec *pathspec,
+ unsigned int refresh_flags);
extern int read_index_preload(struct index_state *,
const struct pathspec *pathspec,
unsigned int refresh_flags);
diff --git a/preload-index.c b/preload-index.c
index 9e7152a..222792c 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -9,7 +9,7 @@
#include "progress.h"
#ifdef NO_PTHREADS
-static void preload_index(struct index_state *index,
+void preload_index(struct index_state *index,
const struct pathspec *pathspec,
unsigned int refresh_flags)
{
@@ -100,9 +100,9 @@ static void *preload_thread(void *_data)
return NULL;
}
-static void preload_index(struct index_state *index,
- const struct pathspec *pathspec,
- unsigned int refresh_flags)
+void preload_index(struct index_state *index,
+ const struct pathspec *pathspec,
+ unsigned int refresh_flags)
{
int threads, i, work, offset;
struct thread_data data[MAX_PARALLEL];
diff --git a/read-cache.c b/read-cache.c
index d579582..53733d6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1496,6 +1496,12 @@ int refresh_index(struct index_state *istate, unsigned int flags,
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+ /*
+ * Use the multi-threaded preload_index() to refresh most of the
+ * cache entries quickly then in the single threaded loop below,
+ * we only have to do the special cases that are left.
+ */
+ preload_index(istate, pathspec, 0);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;