Skip to content

Commit

Permalink
Merge pull request git-for-windows#971 from jeffhostetler/jeffhostetl…
Browse files Browse the repository at this point in the history
…er/add_preload_fscache

add: use preload-index and fscache for performance
  • Loading branch information
dscho committed Nov 29, 2016
2 parents 7d0be42 + 0b70192 commit 2cfb5e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE,
prefix, argv);

enable_fscache(1);
/* We do not really re-read the index, but update the up-to-date flags */
preload_index(&the_index, &pathspec);

if (add_new_files) {
int baselen;

Expand Down
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ 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 *, const struct pathspec *pathspec);
extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
extern int do_read_index(struct index_state *istate, const char *path,
int must_exist); /* for testting only! */
Expand Down
6 changes: 2 additions & 4 deletions preload-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#include "dir.h"

#ifdef NO_PTHREADS
static void preload_index(struct index_state *index,
const struct pathspec *pathspec)
void preload_index(struct index_state *index, const struct pathspec *pathspec)
{
; /* nothing */
}
Expand Down Expand Up @@ -71,8 +70,7 @@ static void *preload_thread(void *_data)
return NULL;
}

static void preload_index(struct index_state *index,
const struct pathspec *pathspec)
void preload_index(struct index_state *index, const struct pathspec *pathspec)
{
int threads, i, work, offset;
struct thread_data data[MAX_PARALLEL];
Expand Down

0 comments on commit 2cfb5e5

Please sign in to comment.