From: Nick Bowler Date: Thu, 22 Jun 2023 05:20:12 +0000 (-0400) Subject: libcdecl: Simplify cdecl__explain_specs. X-Git-Tag: v1.3~156 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/306005996991bea30a81ccbe923f455b752bcbeb 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. --- 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;