refresh_index: remove unnecessary calls to preload_index()
authorBen Peart <benpeart@microsoft.com>
Mon, 5 Nov 2018 19:27:51 +0000 (14:27 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Nov 2018 03:49:59 +0000 (12:49 +0900)
With refresh_index() learning to utilize preload_index() to speed up its
operation there is no longer any benefit to having the caller preload the
index first. Remove those unneeded calls by calling read_index() instead of
the preload variant.

There is no measurable performance impact of this patch - the 2nd call to
preload_index() bails out quickly but there is no reason to call it twice.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c
builtin/describe.c
builtin/update-index.c
sequencer.c
index 074bd9a55160a8efcaa1c108afcf6bd6bc360626..96d336ec3d8044918fb260d6cf8c03296cf32ed1 100644 (file)
@@ -1363,7 +1363,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        if (status_format != STATUS_FORMAT_PORCELAIN &&
            status_format != STATUS_FORMAT_PORCELAIN_V2)
                progress_flag = REFRESH_PROGRESS;
-       read_index_preload(&the_index, &s.pathspec, progress_flag);
+       read_index(&the_index);
        refresh_index(&the_index,
                      REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,
                      &s.pathspec, NULL, NULL);
index c48c34e8667c36a42101fffe51bd96f1a4d36842..cc118448ee00d2c4336422afbad1799babfb5783 100644 (file)
@@ -629,7 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                        struct argv_array args = ARGV_ARRAY_INIT;
                        int fd, result;
 
-                       read_cache_preload(NULL);
+                       read_cache();
                        refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
                                      NULL, NULL, NULL);
                        fd = hold_locked_index(&index_lock, 0);
index 07c10bcb7d82c19becf424f9ab63954c9e58f93f..0e1dcf0438f7b2ec37b404d3f2acb7bd70650b67 100644 (file)
@@ -782,7 +782,7 @@ struct refresh_params {
 static int refresh(struct refresh_params *o, unsigned int flag)
 {
        setup_work_tree();
-       read_cache_preload(NULL);
+       read_cache();
        *o->has_errors |= refresh_cache(o->flags | flag);
        return 0;
 }
index 0c164d5f98f152156ef21a79159f6348fecb0273..b46dd0fb636724d333f3dacdf43a93fa1c266661 100644 (file)
@@ -1913,7 +1913,7 @@ static int read_and_refresh_cache(struct replay_opts *opts)
 {
        struct lock_file index_lock = LOCK_INIT;
        int index_fd = hold_locked_index(&index_lock, 0);
-       if (read_index_preload(&the_index, NULL, 0) < 0) {
+       if (read_index(&the_index) < 0) {
                rollback_lock_file(&index_lock);
                return error(_("git %s: failed to read the index"),
                        _(action_name(opts)));