summaryrefslogtreecommitdiff
path: root/sfeed_web.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2019-04-06 14:58:37 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2019-04-06 14:58:37 +0200
commit91f51eb809e13021cef3342b2688dc354c3f9c9e (patch)
tree17494744d06471bcba0898d849432e3f37dbebc4 /sfeed_web.c
parent5a3995ae274b7fa19823a5fae72afe1c493a4c44 (diff)
optimization: define GETNEXT as an inline macro
This reduces much function call overhead. getnext is defined in xml.h for inline optimization. sfeed only uses one XML parser context per program, this allows further optimizations of the compiler also. On OpenBSD it was noticable because of retpoline etc function call overhead. Using clang and a 500MB test XML file reduces processing time from +- 12s to 5s. Tested using some crazy optimization flags: SFEED_CFLAGS = -O3 -std=c99 -DGETNEXT=getchar_unlocked -fno-ret-protector \ -mno-retpoline -static A GETNEXT macro is also nice for programs which mmap(2) some big XML file. Then you can simply define: #define GETNEXT() (off >= len ? EOF : reg[off++])
Diffstat (limited to 'sfeed_web.c')
-rw-r--r--sfeed_web.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sfeed_web.c b/sfeed_web.c
index 11291d9..676e211 100644
--- a/sfeed_web.c
+++ b/sfeed_web.c
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
parser.xmltagstart = xmltagstart;
parser.xmltagstartparsed = xmltagstartparsed;
- parser.getnext = getchar;
+ /* NOTE: getnext is defined in xml.h for inline optimization */
xml_parse(&parser);
return found > 0 ? 0 : 1;