]> granicus.if.org Git - graphviz/commit
optimize two calls to gvprintf with single characters
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 21 May 2021 02:34:36 +0000 (19:34 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 27 May 2021 04:26:38 +0000 (21:26 -0700)
commitc54470e710964d566bce944befcbd048c0581567
tree8746a3f83efb1acc593b6c8737fc7eba6f7e0bfa
parent8a04d6fa0748d2752b9a43eac5bba297a8a0e7ff
optimize two calls to gvprintf with single characters

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%.
plugin/core/gvrender_core_svg.c