]> git.draconx.ca Git - cdecl99.git/commitdiff
libcdecl: Simplify cdecl__explain_specs.
authorNick Bowler <nbowler@draconx.ca>
Thu, 22 Jun 2023 05:20:12 +0000 (01:20 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 22 Jun 2023 05:22:14 +0000 (01:22 -0400)
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

index f52661dc6debd7d4080d02f401f60cddfa1daa7a..a8d7ea5ade969fef29be01855623105106e57dfe 100644 (file)
@@ -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;