fprintunderline: small optimization

Don't run utf8strlen potentially for each character.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
master
Hiltjo Posthuma 2020-04-29 19:31:59 +02:00 committed by Christoph Lohmann
parent 0e58fcdb30
commit 44f42507f8
1 changed files with 3 additions and 2 deletions

View File

@ -25,10 +25,11 @@ utf8strlen(const char *s)
void void
fprintunderline(FILE *fp, const char *str) fprintunderline(FILE *fp, const char *str)
{ {
size_t i; size_t i, len;
fprintf(fp, "\n %s\n ", str); fprintf(fp, "\n %s\n ", str);
for (i = 0; i <= utf8strlen(str); ++i) len = utf8strlen(str);
for (i = 0; i <= len; ++i)
fputs("=", fp); fputs("=", fp);
fputs("\n\n", fp); fputs("\n\n", fp);
} }