[PATCH 1/4] worktree: drop pointless strbuf_release()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---

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(-)

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;
 }
 
-- 
2.28.0.203.gce1f2e0ef1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux