The expression `gvprintf(j, "%c", x)` is equivalent to `gvwrite(j, &x, 1)`.
However, it seems modern compilers, even with link-time optimization enabled,
are not clever enough to see this equivalence. By unraveling the gvprintf call
to what it eventually bottoms out to, we can accelerate SVG generation.
On tests/regression_tests/large/long_chain, this drops the number of gvprintf
calls from 297008 to 165008, reducing the amount of the trace for which gvprintf
is responsible from 3.27% to 2.24%. Total executed instructions are reduced from
8160974807 to
8098098396, a speed up of ~1%.
if (A[0].x <= A[n-1].x) {
#endif
for (i = 0; i < n; i++) {
- gvprintf(job, "%c", c);
+ gvwrite(job, &c, 1);
gvprintdouble(job, A[i].x);
gvputs(job, ",");
gvprintdouble(job, -A[i].y);
#if EDGEALIGN
} else {
for (i = n-1; i >= 0; i--) {
- gvprintf(job, "%c", c);
+ gvwrite(job, &c, 1);
gvprintdouble(job, A[i].x);
gvputs(job, ",");
gvprintdouble(job, -A[i].y);