diff options
| author | lhchavez <lhchavez@lhchavez.com> | 2020-12-11 05:08:45 -0800 |
|---|---|---|
| committer | lhchavez <lhchavez@lhchavez.com> | 2020-12-11 05:09:47 -0800 |
| commit | 6cd0c8534d81509a330b09f619fe3249f1d121d2 (patch) | |
| tree | da65cb19dbc6dd6fb692d808f554c6e45bd8091b /src/diff_generate.c | |
| parent | 41da4e16eb01a7bb19c52bbc4251963be192ba69 (diff) | |
| download | libgit2-6cd0c8534d81509a330b09f619fe3249f1d121d2.tar.gz | |
Small refactor to make thing tidier
Also repurposed an unused function and deleted another one.
Diffstat (limited to 'src/diff_generate.c')
| -rw-r--r-- | src/diff_generate.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/diff_generate.c b/src/diff_generate.c index bc7c26658..f05ae3713 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -709,18 +709,12 @@ static int maybe_modified_submodule( } else { if (!info->submodule_cache_initialized) { info->submodule_cache_initialized = true; - /* Cache the submodule information to avoid having to parse it for every submodule. */ - if (git_strmap_new(&info->submodule_cache) == 0) { - if (git_submodule__map(diff->base.repo, info->submodule_cache) < 0) { - /* If the caching failed for whatever reason, bail out and clean up. */ - git_submodule *sm = NULL; - git_strmap_foreach_value(info->submodule_cache, sm, { - git_submodule_free(sm); - }); - git_strmap_free(info->submodule_cache); - info->submodule_cache = NULL; - } - } + /* + * Try to cache the submodule information to avoid having to parse it for + * every submodule. It is okay if it fails, the cache will still be NULL + * and the submodules will be attempted to be looked up individually. + */ + git_submodule_cache_init(&info->submodule_cache, diff->base.repo); } submodule_cache = info->submodule_cache; } @@ -1284,13 +1278,8 @@ cleanup: *out = &diff->base; else git_diff_free(&diff->base); - if (info.submodule_cache) { - git_submodule *sm = NULL; - git_strmap_foreach_value(info.submodule_cache, sm, { - git_submodule_free(sm); - }); - git_strmap_free(info.submodule_cache); - } + if (info.submodule_cache) + git_submodule_cache_free(info.submodule_cache); return error; } |
