Skip to content

Commit 0df26ee

Browse files
committed
Merge pull request #971 from jeffhostetler/jeffhostetler/add_preload_fscache
add: use preload-index and fscache for performance
2 parents 86d188e + 5c0ebd2 commit 0df26ee

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

builtin/add.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
389389
PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE,
390390
prefix, argv);
391391

392+
enable_fscache(1);
393+
/* We do not really re-read the index, but update the up-to-date flags */
394+
preload_index(&the_index, &pathspec);
395+
392396
if (add_new_files) {
393397
int baselen;
394398

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ extern int daemonize(void);
575575
/* Initialize and use the cache information */
576576
struct lock_file;
577577
extern int read_index(struct index_state *);
578+
extern void preload_index(struct index_state *, const struct pathspec *pathspec);
578579
extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
579580
extern int do_read_index(struct index_state *istate, const char *path,
580581
int must_exist); /* for testting only! */

preload-index.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#include "dir.h"
77

88
#ifdef NO_PTHREADS
9-
static void preload_index(struct index_state *index,
10-
const struct pathspec *pathspec)
9+
void preload_index(struct index_state *index, const struct pathspec *pathspec)
1110
{
1211
; /* nothing */
1312
}
@@ -71,8 +70,7 @@ static void *preload_thread(void *_data)
7170
return NULL;
7271
}
7372

74-
static void preload_index(struct index_state *index,
75-
const struct pathspec *pathspec)
73+
void preload_index(struct index_state *index, const struct pathspec *pathspec)
7674
{
7775
int threads, i, work, offset;
7876
struct thread_data data[MAX_PARALLEL];

0 commit comments

Comments
 (0)