summaryrefslogtreecommitdiff
path: root/builtin/difftool.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-11-11 20:02:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-11 20:55:27 (GMT)
commitb19315d8ab46ae50410dba9228a4c08ae5c73e38 (patch)
treef473f15041b2f515f50aacdda428825e884eb18d /builtin/difftool.c
parent23a276a9c4c8945aadbc323e12c970816eb43c27 (diff)
downloadgit-b19315d8ab46ae50410dba9228a4c08ae5c73e38.zip
git-b19315d8ab46ae50410dba9228a4c08ae5c73e38.tar.gz
git-b19315d8ab46ae50410dba9228a4c08ae5c73e38.tar.bz2
Use new HASHMAP_INIT macro to simplify hashmap initialization
Now that hashamp has lazy initialization and a HASHMAP_INIT macro, hashmaps allocated on the stack can be initialized without a call to hashmap_init() and in some cases makes the code a bit shorter. Convert some callsites over to take advantage of this. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/difftool.c')
-rw-r--r--builtin/difftool.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 7ac432b..6e18e62 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -342,7 +342,10 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
const char *workdir, *tmp;
int ret = 0, i;
FILE *fp;
- struct hashmap working_tree_dups, submodules, symlinks2;
+ struct hashmap working_tree_dups = HASHMAP_INIT(working_tree_entry_cmp,
+ NULL);
+ struct hashmap submodules = HASHMAP_INIT(pair_cmp, NULL);
+ struct hashmap symlinks2 = HASHMAP_INIT(pair_cmp, NULL);
struct hashmap_iter iter;
struct pair_entry *entry;
struct index_state wtindex;
@@ -383,10 +386,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
rdir_len = rdir.len;
wtdir_len = wtdir.len;
- hashmap_init(&working_tree_dups, working_tree_entry_cmp, NULL, 0);
- hashmap_init(&submodules, pair_cmp, NULL, 0);
- hashmap_init(&symlinks2, pair_cmp, NULL, 0);
-
child.no_stdin = 1;
child.git_cmd = 1;
child.use_shell = 0;