improve commitinfo_getstats
- reorder: unnecessary allocation when git_patch_from_diff fails. - no need to free patch object when git_patch_from_diff fails.
1 files changed, 2 insertions(+), 5 deletions(-) | |||
---|---|---|---|
M | stagit.c | +2 | -5 |
1@@ -110,13 +110,10 @@ commitinfo_getstats(struct commitinfo *ci)
2 err(1, "calloc");
3
4 for (i = 0; i < ndeltas; i++) {
5+ if (git_patch_from_diff(&patch, ci->diff, i))
6+ goto err;
7 if (!(di = calloc(1, sizeof(struct deltainfo))))
8 err(1, "calloc");
9- if (git_patch_from_diff(&patch, ci->diff, i)) {
10- git_patch_free(patch);
11- free(di);
12- goto err;
13- }
14 di->patch = patch;
15 ci->deltas[i] = di;
16