xmlencode: optimize common character output function

Use putc instead of fputc, it can be optimized to macros.

From the OpenBSD man page:

"    putc() acts essentially identically to fputc(), but is a macro that
     expands in-line.  It may evaluate stream more than once, so arguments
     given to putc() should not be expressions with potential side effects."

sfeed_atom, sfeed_frames and sfeed_html are using this function.

Mini-benchmarked sfeed_html and it went from 1.45s to 1.0s with feed files in
total 250k lines (+- 350MB). Tested with clang and gcc on OpenBSD on an older
laptop.
This commit is contained in:
Hiltjo Posthuma 2021-01-08 11:58:48 +01:00
parent b829948d9d
commit bb34ab8d50
1 changed files with 1 additions and 1 deletions

2
util.c
View File

@ -222,7 +222,7 @@ xmlencode(const char *s, FILE *fp)
case '\'': fputs("'", fp); break;
case '&': fputs("&", fp); break;
case '"': fputs(""", fp); break;
default: fputc(*s, fp);
default: putc(*s, fp);
}
}
}