From 306005996991bea30a81ccbe923f455b752bcbeb Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 22 Jun 2023 01:20:12 -0400 Subject: [PATCH] libcdecl: Simplify cdecl__explain_specs. A bunch of conditions in the specifier printing loop are meaningless, since all valid specifier types take idenical execution paths through this function. So much of this can just be deleted. --- src/output.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/output.c b/src/output.c index f52661d..a8d7ea5 100644 --- a/src/output.c +++ b/src/output.c @@ -70,15 +70,12 @@ size_t cdecl__explain_specs(char *buf, size_t n, struct cdecl_declspec *s, { size_t ret = 0, rc = 0; - for (struct cdecl_declspec *c = s; c; c = c->next) { - switch (cdecl_spec_kind(c) & mask) { - case CDECL_SPEC_FUNC: - case CDECL_SPEC_STOR: - case CDECL_SPEC_QUAL: - case CDECL_SPEC_TYPE: - ret += cdecl__advance(&buf, &n, rc); - rc = explain_spec(buf, n, c); - } + for (; s; s = s->next) { + if (!(s->type & mask)) + continue; + + ret += cdecl__advance(&buf, &n, rc); + rc = explain_spec(buf, n, s); } return ret + rc; -- 2.43.2