Thread (5 messages) 5 messages, 1 author, 2021-10-01

[PATCH v7 3/4] difftool: remove an unnecessary call to strbuf_release()

flat view
STALE1833d

From: David Aguilar <hidden>
Date: 2021-10-01 01:38:08
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 builtin/difftool.c | 2 --
 1 file changed, 2 deletions(-)
diff --git a/builtin/difftool.c b/builtin/difftool.c
index f3cd1e5b53..437474fea0 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -568,8 +568,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
 		write_standin_files(entry, &ldir, ldir_len, &rdir, rdir_len);
 	}
 
-	strbuf_release(&buf);
-
 	strbuf_setlen(&ldir, ldir_len);
 	helper_argv[1] = ldir.buf;
 	strbuf_setlen(&rdir, rdir_len);
-- 
2.33.0.886.g5b6dfe5e5c
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help