]> granicus.if.org Git - graphviz/commitdiff
convert some gvprintf calls with no format codes to gvputs
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 21 May 2021 02:21:21 +0000 (19:21 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 27 May 2021 04:26:38 +0000 (21:26 -0700)
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.

plugin/core/gvrender_core_svg.c

index 610db652636640c7bec64f2ab2ee365bd52de028..8a6c4989b3f2e6ae62eee6e591811b193211845d 100644 (file)
@@ -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, "</tspan></textPath>");
+       gvputs(job, "</tspan></textPath>");
     gvputs(job, "</text>\n");
 }