Skip to content

Commit d6651df

Browse files
committed
Merge pull request #971 from jeffhostetler/jeffhostetler/add_preload_fscache
add: use preload-index and fscache for performance
2 parents b772a4d + 8bf7774 commit d6651df

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
@@ -440,6 +440,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
440440

441441
die_path_inside_submodule(&the_index, &pathspec);
442442

443+
enable_fscache(1);
444+
/* We do not really re-read the index but update the up-to-date flags */
445+
preload_index(&the_index, &pathspec);
446+
443447
if (add_new_files) {
444448
int baselen;
445449

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ extern int daemonize(void);
596596
/* Initialize and use the cache information */
597597
struct lock_file;
598598
extern int read_index(struct index_state *);
599+
extern void preload_index(struct index_state *, const struct pathspec *pathspec);
599600
extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
600601
extern int do_read_index(struct index_state *istate, const char *path,
601602
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
}
@@ -69,8 +68,7 @@ static void *preload_thread(void *_data)
6968
return NULL;
7069
}
7170

72-
static void preload_index(struct index_state *index,
73-
const struct pathspec *pathspec)
71+
void preload_index(struct index_state *index, const struct pathspec *pathspec)
7472
{
7573
int threads, i, work, offset;
7674
struct thread_data data[MAX_PARALLEL];

0 commit comments

Comments
 (0)