git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
David Aguilar <davvid@gmail.com>
Date
Sep 30, 2021, 17:01 UTC
Message-ID
<20210930170146.61489-5-davvid@gmail.com>
In-Reply-To
<20210930170146.61489-1-davvid@gmail.com>

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 --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);
-- 
2.33.0.887.g8db6ae3373
Previous: David AguilarNext: Junio C Hamano
Message 10 of 11 in “difftool: create a tmpdir path without repeated slashes”
  1. 1/5 difftool: create a tmpdir path without repeated slashesDavid Aguilar, Sep 30, 2021
  2. 2/5 difftool: add a missing space to the run_dir_diff() commentsDavid Aguilar, Sep 30, 2021
  3. 3/5 difftool: avoid returning -1 to cmd_main() from run_dir_diff()David Aguilar, Sep 30, 2021
  4. Junio C HamanoSep 30, 2021
  5. David AguilarSep 30, 2021
  6. Junio C HamanoOct 1, 2021
  7. 4/5 difftool: refactor dir-diff to write files using a helper functionDavid Aguilar, Sep 30, 2021
  8. Junio C HamanoSep 30, 2021
  9. David AguilarSep 30, 2021
  10. 5/5 difftool: remove an unnecessary call to strbuf_release()David Aguilar, Sep 30, 2021
  11. Junio C HamanoSep 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.