From: Matthew Fernandez Date: Fri, 21 May 2021 02:21:21 +0000 (-0700) Subject: convert some gvprintf calls with no format codes to gvputs X-Git-Tag: 2.47.3~31^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a04d6fa0748d2752b9a43eac5bba297a8a0e7ff;p=graphviz convert some gvprintf calls with no format codes to gvputs This is equivalent, but gvputs is less expensive to call than gvprintf. Surprisingly,¹ with link-time optimization a compiler is able to see this optimization for itself, so this makes no difference to performance in an LTO build. However, this should be a slight optimization in non-LTO builds. ¹ I say surprisingly because compilers generally do not attempt inter-procedural optimization across varargs calls. The calling convention and interpretation of arguments is complex enough that they generally conservatively leave such calls alone. --- diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 610db6526..8a6c4989b 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -426,14 +426,14 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) gvprintf(job, " font-family=\"%s\"", span->font->name); if ((span->font) && (flags = span->font->flags)) { if ((flags & HTML_BF) && !weight) - gvprintf(job, " font-weight=\"bold\""); + gvputs(job, " font-weight=\"bold\""); if ((flags & HTML_IF) && !style) - gvprintf(job, " font-style=\"italic\""); + gvputs(job, " font-style=\"italic\""); if ((flags & (HTML_UL|HTML_S|HTML_OL))) { int comma = 0; - gvprintf(job, " text-decoration=\""); + gvputs(job, " text-decoration=\""); if ((flags & HTML_UL)) { - gvprintf(job, "underline"); + gvputs(job, "underline"); comma = 1; } if ((flags & HTML_OL)) { @@ -442,12 +442,12 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) } if ((flags & HTML_S)) gvprintf(job, "%sline-through", (comma?",":"")); - gvprintf(job, "\""); + gvputs(job, "\""); } if ((flags & HTML_SUP)) - gvprintf(job, " baseline-shift=\"super\""); + gvputs(job, " baseline-shift=\"super\""); if ((flags & HTML_SUB)) - gvprintf(job, " baseline-shift=\"sub\""); + gvputs(job, " baseline-shift=\"sub\""); } gvprintf(job, " font-size=\"%.2f\"", span->font->size); @@ -475,7 +475,7 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) } gvputs(job, xml_string0(span->str, TRUE)); if (obj->labeledgealigned) - gvprintf (job, ""); + gvputs(job, ""); gvputs(job, "\n"); }