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