fprintunderline: small optimization - pointtools - Simple point utilities to ho… | |
git clone git://bitreich.org/pointtools/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfr… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit 44f42507f8b54d6f3c96869275077ee39dae18d8 | |
parent 0e58fcdb306d8383ead9eafdcd6666515a44ab50 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 29 Apr 2020 19:31:59 +0200 | |
fprintunderline: small optimization | |
Don't run utf8strlen potentially for each character. | |
Signed-off-by: Christoph Lohmann <[email protected]> | |
Diffstat: | |
M md2point.c | 5 +++-- | |
1 file changed, 3 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/md2point.c b/md2point.c | |
@@ -25,10 +25,11 @@ utf8strlen(const char *s) | |
void | |
fprintunderline(FILE *fp, const char *str) | |
{ | |
- size_t i; | |
+ size_t i, len; | |
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("\n\n", fp); | |
} |