3 ms·
For readability, this is reasonable. There may be a cost that it weakens some static analyzers, but I don't program in C enough to be sure. For performance, th
by dchftcs 4y ago
For readability, this is reasonable. There may be a cost that it weakens some static analyzers, but I don't program in C enough to be sure.
For performance, this is not necessary because the compiler can optimize long switch-case flow into dispatch tables: https://godbolt.org/z/7WxEfc6YM https://godbolt.org/z/7WxEfc6YM
- elpescado 4y ago> For readability, this is reasonable. With four branches, maybe. With more branches, having array of tens of function pointers makes hard to tell which index maps to which function call. OTOH, that can somehow be mitigated (at least in C99) with designated initialisers.