worktree.c: avoid referencing to worktrees[i] multiple times

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 22, 2016 at 20:01 UTC c8717148d02c48340ffd6a01ca52c31fa374bf3c
1 file changed +4 -2
worktree.c
+4 -2
@@ -229,10 +229,12 @@ const struct worktree *find_shared_symref(const char *symref,
229 worktrees = get_worktrees();
230
231 for (i = 0; worktrees[i]; i++) {
232 + struct worktree *wt = worktrees[i];
233 +
234 strbuf_reset(&path);
235 strbuf_reset(&sb);
236 strbuf_addf(&path, "%s/%s",
235 - get_worktree_git_dir(worktrees[i]),
237 + get_worktree_git_dir(wt),
238 symref);
239
240 if (parse_ref(path.buf, &sb, NULL)) {
@@ -240,7 +242,7 @@ const struct worktree *find_shared_symref(const char *symref,
242 }
243
244 if (!strcmp(sb.buf, target)) {
243 - existing = worktrees[i];
245 + existing = wt;
246 break;
247 }
248 }