From: Matthew Fernandez Date: Fri, 21 May 2021 03:25:00 +0000 (-0700) Subject: fuse some adjacent gvputs calls X-Git-Tag: 2.47.3~31^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73c2f1e29ace1daf3c35360ade10af404923a3cb;p=graphviz fuse some adjacent gvputs calls On tests/regression_tests/large/long_chain this drops the number of gvputs calls from 2475072 to 2442066, reducing the amount of the trace for which gvputs is responsible from 6.60% to 6.53%. Total executed instructions are reduced from 8098098396 to 8093310656, a speed up of ~0.05%. --- diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index a852b4db1..c4069e846 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -173,18 +173,17 @@ static void svg_begin_job(GVJ_t * job) gvputs(job, s); gvputs(job, "\" type=\"text/css\"?>\n"); } - gvputs(job, "\n"); + gvputs(job, "\n" - gvputs(job, "\n"); + gvputs(job, ")\n" + " -->\n"); } static void svg_begin_graph(GVJ_t * job) @@ -207,10 +206,10 @@ static void svg_begin_graph(GVJ_t * job) job->canvasBox.UR.x, job->canvasBox.UR.y); /* namespace of svg */ - gvputs(job, " xmlns=\"http://www.w3.org/2000/svg\""); + gvputs(job, " xmlns=\"http://www.w3.org/2000/svg\"" /* namespace of xlink */ - gvputs(job, " xmlns:xlink=\"http://www.w3.org/1999/xlink\""); - gvputs(job, ">\n"); + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + ">\n"); } static void svg_end_graph(GVJ_t * job) @@ -273,8 +272,8 @@ static void svg_begin_cluster(GVJ_t * job) obj_state_t *obj = job->obj; svg_print_id_class(job, obj->id, NULL, "cluster", obj->u.sg); - gvputs(job, ">\n"); - gvputs(job, ""); + gvputs(job, ">\n" + "<title>"); gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, "\n"); } @@ -294,8 +293,8 @@ static void svg_begin_node(GVJ_t * job) else idx = NULL; svg_print_id_class(job, obj->id, idx, "node", obj->u.n); - gvputs(job, ">\n"); - gvputs(job, ""); + gvputs(job, ">\n" + "<title>"); gvputs(job, xml_string(agnameof(obj->u.n))); gvputs(job, "\n"); } @@ -311,9 +310,9 @@ static void svg_begin_edge(GVJ_t * job) char *ename; svg_print_id_class(job, obj->id, NULL, "edge", obj->u.e); - gvputs(job, ">\n"); + gvputs(job, ">\n" - gvputs(job, ""); + "<title>"); ename = strdup_and_subst_obj("\\E", (void *) (obj->u.e)); gvputs(job, xml_string(ename)); free(ename); @@ -335,9 +334,9 @@ svg_begin_anchor(GVJ_t * job, char *href, char *tooltip, char *target, gvputs(job, xml_string(id)); gvputs(job, "\""); } - gvputs(job, ">"); + gvputs(job, ">" - gvputs(job, "<a"); + "<a"); if (href && href[0]) { gvputs(job, " xlink:href=\""); gvputs(job, xml_url_string(href)); @@ -358,8 +357,8 @@ svg_begin_anchor(GVJ_t * job, char *href, char *tooltip, char *target, static void svg_end_anchor(GVJ_t * job) { - gvputs(job, "</a>\n"); - gvputs(job, "</g>\n"); + gvputs(job, "</a>\n" + "</g>\n"); } static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) @@ -561,8 +560,8 @@ static int svg_rgradstyle(GVJ_t * job) gvprintf(job, "%f", ((float) obj->fillcolor.u.rgba[3] / 255.0)); else gvputs(job, "1."); - gvputs(job, ";\"/>\n"); - gvputs(job, "<stop offset=\"1\" style=\"stop-color:"); + gvputs(job, ";\"/>\n" + "<stop offset=\"1\" style=\"stop-color:"); svg_print_color(job, obj->stopcolor); gvputs(job, ";stop-opacity:"); if (obj->stopcolor.type == RGBA_BYTE && obj->stopcolor.u.rgba[3] > 0