On 2023-08-04 03:00, Alejandro Colomar wrote: > * src/roff/troff/env.cpp (is_family_valid): The old code was > eyeball-bleeding. This cuts 6 lines to 3, and each of them is > significantly simpler to read. Remove the comments of how it could > be improved using modern C++, as I don't think it would improve much > vs this C implementation. > > Signed-off-by: Alejandro Colomar <[email protected]> > ---
Disclaimer: I did a build, but didn't really try it.
>
> I need a new pair of eyeballs. They bleeded so much!
>
> src/roff/troff/env.cpp | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
> index 106ab6889..23d81275a 100644
> --- a/src/roff/troff/env.cpp
> +++ b/src/roff/troff/env.cpp
> @@ -1260,14 +1260,10 @@ void font_change()
>
> bool is_family_valid(const char *fam)
> {
> - // std::vector<const char *> styles{"R", "I", "B", "BI"}; // C++11
> - const size_t nstyles = 4;
> - const char *st[nstyles] = { "R", "I", "B", "BI" };
> - std::vector<const char *> styles(st, (st + nstyles));
> - // for (auto style : styles) // C++11
> - std::vector<const char *>::iterator style;
> - for (style = styles.begin(); style != styles.end(); style++)
> - if (!check_font(fam, *style))
> + static const char styles[][3] = { "R", "I", "B", "BI" };
> +
> + for (size_t i = 0; i < lengthof(styles); i++)
> + if (!check_font(fam, styles[i]))
> return false;
> return true;
> }
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
OpenPGP_signature
Description: OpenPGP digital signature
