From 91f51eb809e13021cef3342b2688dc354c3f9c9e Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 6 Apr 2019 14:58:37 +0200 Subject: 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++]) --- sfeed_opml_import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfeed_opml_import.c') diff --git a/sfeed_opml_import.c b/sfeed_opml_import.c index 361b80f..4108b20 100644 --- a/sfeed_opml_import.c +++ b/sfeed_opml_import.c @@ -97,7 +97,7 @@ main(void) "# list of feeds to fetch:\n" "feeds() {\n" " # feed [basesiteurl] [encoding]\n", stdout); - parser.getnext = getchar; + /* NOTE: getnext is defined in xml.h for inline optimization */ xml_parse(&parser); fputs("}\n", stdout); -- cgit v1.2.3