From: Matthew Fernandez Date: Thu, 8 Sep 2022 00:27:49 +0000 (-0700) Subject: dotgen _dot_splines: remove micro-optimization for single edge X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=201f4c729bbb86f8933c2d520e018fb9c3808377;p=graphviz dotgen _dot_splines: remove micro-optimization for single edge This code was attempting to avoid heap allocation when dealing with a single edge. This kind of micro-optimization is unnecessary with modern allocators/compilers. The cost of anything here is most likely irrelevant compared to the massive size of the containing function. --- diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 17f52e940..deac45338 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -422,18 +422,12 @@ static void _dot_splines(graph_t * g, int normalize) if (et == EDGETYPE_CURVED) { int ii; - edge_t* e0; - edge_t** edgelist; - if (cnt == 1) - edgelist = &e0; - else - edgelist = gv_calloc(cnt, sizeof(edge_t*)); + edge_t** edgelist = gv_calloc(cnt, sizeof(edge_t*)); edgelist[0] = getmainedge((edges+ind)[0]); for (ii = 1; ii < cnt; ii++) edgelist[ii] = (edges+ind)[ii]; makeStraightEdges (g, edgelist, cnt, et, &sinfo); - if (cnt > 1) - free (edgelist); + free(edgelist); } else if (agtail(e0) == aghead(e0)) { int b, r;