fprintunderline: small optimization - pointtools - Simple point utilities to hold text presentations. HTML git clone git://bitreich.org/pointtools/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/pointtools/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 44f42507f8b54d6f3c96869275077ee39dae18d8 DIR parent 0e58fcdb306d8383ead9eafdcd6666515a44ab50 HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org> 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 <20h@r-36.net> Diffstat: M md2point.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- DIR 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); }