[1/4] worktree: drop pointless strbuf_release()
diff mbox series

Message ID 20200731233214.22131-2-sunshine@sunshineco.com
State New
Headers show
Series
  • worktree: cleanups & simplification
Related show

Commit Message

Eric Sunshine July 31, 2020, 11:32 p.m. UTC
The content of this strbuf is unconditionally detached several lines
before the strbuf_release() and the strbuf is never touched again after
that point.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

Notes:
    I'm on the fence about this change. On the one hand, I spent extra
    cycles studying the code to determine if the strbuf was used again
    after being detached. On the other hand, the strbuf_release() at the
    end of the function protects against a leak if someone ever inserts
    code which re-uses the strbuf. So, I wouldn't be bothered if this
    patch is dropped from the series.

 worktree.c | 2 --
 1 file changed, 2 deletions(-)

Patch
diff mbox series

diff --git a/worktree.c b/worktree.c
index cba2e54598..c0df5e2c79 100644
--- a/worktree.c
+++ b/worktree.c
@@ -66,8 +66,6 @@  static struct worktree *get_main_worktree(void)
 	worktree->is_bare = (is_bare_repository_cfg == 1) ||
 		is_bare_repository();
 	add_head_info(worktree);
-
-	strbuf_release(&worktree_path);
 	return worktree;
 }