[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    [PATCH 1/4] worktree: drop pointless strbuf_release()
From:       Eric Sunshine <sunshine () sunshineco ! com>
Date:       2020-07-31 23:32:11
Message-ID: 20200731233214.22131-2-sunshine () sunshineco ! com
[Download RAW message or body]

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

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic