Skip to content

Commit f4334c8

Browse files
committed
Merge pull request #971 from jeffhostetler/jeffhostetler/add_preload_fscache
add: use preload-index and fscache for performance
2 parents 160a260 + 5e87197 commit f4334c8

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
@@ -609,6 +609,7 @@ extern int daemonize(void);
609609
/* Initialize and use the cache information */
610610
struct lock_file;
611611
extern int read_index(struct index_state *);
612+
extern void preload_index(struct index_state *, const struct pathspec *pathspec);
612613
extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
613614
extern int do_read_index(struct index_state *istate, const char *path,
614615
int must_exist); /* for testting only! */

preload-index.c

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

99
#ifdef NO_PTHREADS
10-
static void preload_index(struct index_state *index,
11-
const struct pathspec *pathspec)
10+
void preload_index(struct index_state *index, const struct pathspec *pathspec)
1211
{
1312
; /* nothing */
1413
}
@@ -73,8 +72,7 @@ static void *preload_thread(void *_data)
7372
return NULL;
7473
}
7574

76-
static void preload_index(struct index_state *index,
77-
const struct pathspec *pathspec)
75+
void preload_index(struct index_state *index, const struct pathspec *pathspec)
7876
{
7977
int threads, i, work, offset;
8078
struct thread_data data[MAX_PARALLEL];

0 commit comments

Comments
 (0)