diff mbox series

[v6,5/5] difftool: remove an unnecessary call to strbuf_release()

Message ID 20210930170146.61489-5-davvid@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v6,1/5] difftool: create a tmpdir path without repeated slashes | expand

Commit Message

David Aguilar Sept. 30, 2021, 5:01 p.m. UTC
The `buf` strbuf is reused again later in the same function, so there
is no benefit to calling strbuf_release(). The subsequent usage is
already using strbuf_reset() to reset the buffer, so releasing it
early is only going to lead to a wasteful reallocation.

Remove the early call to strbuf_release(). The same strbuf is already
cleaned up in the "finish:" section so nothing is leaked, either.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
This is a small cleanup that I noticed while working on the new patches.
There are no previous versions of this patch.

 builtin/difftool.c | 2 --
 1 file changed, 2 deletions(-)
diff mbox series

Patch

diff --git a/builtin/difftool.c b/builtin/difftool.c
index bbb8b399c2..859ccc6db3 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -560,8 +560,6 @@  static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
 		write_entry(entry->path, entry->right, &rdir, rdir_len);
 	}
 
-	strbuf_release(&buf);
-
 	strbuf_setlen(&ldir, ldir_len);
 	helper_argv[1] = ldir.buf;
 	strbuf_setlen(&rdir, rdir_len);