Subject: [PATCH v2 08/12] worktree.c: avoid referencing to worktrees[i] multiple times

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Wed, 20 Apr 2016 20:24:49 +0700

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 worktree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/worktree.c b/worktree.c
index 452f64a..b5ca78f 100644
--- a/worktree.c
+++ b/worktree.c
@@ -221,10 +221,12 @@ const struct worktree *find_shared_symref(const char *symref,
 	worktrees = get_worktrees();
 
 	for (i = 0; worktrees[i]; i++) {
+		struct worktree *wt = worktrees[i];
+
 		strbuf_reset(&path);
 		strbuf_reset(&sb);
 		strbuf_addf(&path, "%s/%s",
-			    get_worktree_git_dir(worktrees[i]),
+			    get_worktree_git_dir(wt),
 			    symref);
 
 		if (parse_ref(path.buf, &sb, NULL)) {
@@ -232,7 +234,7 @@ const struct worktree *find_shared_symref(const char *symref,
 		}
 
 		if (!strcmp(sb.buf, target)) {
-			existing = worktrees[i];
+			existing = wt;
 			break;
 		}
 	}
-- 
2.8.0.rc0.210.gd302cd2