Re: [PATCH v3 2/6] path.c: new (identical) list for worktree v1
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 27, 2016, 22:18 UTC
- Message-ID
- <xmqqbn867jl3.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1453808685-21235-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 9 quoted lines
> +static struct common_dir common_list_v1[] = {
> + ...
> +};
> +
> +static struct common_dir *get_common_list(void)
> +{
> + switch (repository_format_worktree_version) {
> + case 0: return common_list_v0;
> + case 1: return common_list_v1;Why not an array whose elements are these common_list_v$N[] instead of "switch"? I.e.
static struct common_dir **common_list_version[] = {
common_list_v0,
common_list_v1,
};static struct common_dir *get_common_list(void)
{
int i = repository_format_worktree_version;
if (i < ARRAY_SIZE(common_list_version))
return common_list_version[i];
die("I dunno about version %d", i);
}