summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-01-08 11:58:48 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-01-08 11:58:48 +0100
commitbb34ab8d50cbe4c9525d06e4cb67fb58e48ae8b8 (patch)
treeed5fd9bf356e4f9e5633eeafd8b0795ab380bdba /util.c
parentb829948d9da8dbbea6d7275ebc1021000114ba15 (diff)
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.
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.c b/util.c
index a91ca2e..1c5f40e 100644
--- a/util.c
+++ b/util.c
@@ -222,7 +222,7 @@ xmlencode(const char *s, FILE *fp)
case '\'': fputs("&#39;", fp); break;
case '&': fputs("&amp;", fp); break;
case '"': fputs("&quot;", fp); break;
- default: fputc(*s, fp);
+ default: putc(*s, fp);
}
}
}