From: Derrick Stolee Date: Thu, 04 Aug 2022 13:31:41 GMT Subject: Re: [PATCH v2 05/10] log-tree: use ref_namespaces instead of if/else-if Message-ID: In-Reply-To: On 8/3/2022 2:31 AM, Junio C Hamano wrote: > "Derrick Stolee via GitGitGadget" writes: > >> From: Derrick Stolee >> + for (i = 0; i < NAMESPACE__COUNT; i++) { >> + struct ref_namespace_info *info = &ref_namespaces[i]; >> + >> + if (!info->decoration) >> + continue; >> + if (info->exact) { >> + if (!strcmp(refname, info->ref)) { >> + deco_type = info->decoration; >> + break; >> + } >> + } else if (starts_with(refname, info->ref)) { >> + deco_type = info->decoration; >> + break; >> + } >> + } > > Very nice. The double-dash in the NAMESPACE__COUNT constant somehow > looks strange. As we scan through ref_namespace[] array densely, > > for (i = 0; i < ARRAY_SIZE(ref_namespace); i++) > ... > > without having to use the constant would probably be more in line > with the way how the rest of the codebase works. Ah, I did not know about that trick. Thanks! -Stolee