]> granicus.if.org Git - graphviz/commitdiff
dotgen _dot_splines: remove micro-optimization for single edge
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Sep 2022 00:27:49 +0000 (17:27 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 29 Jan 2023 16:24:43 +0000 (08:24 -0800)
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.

lib/dotgen/dotsplines.c

index 17f52e940b29c8a3accfc9972fcc3233a5f02311..deac453381d00e6bc06dce6c812593d961055944 100644 (file)
@@ -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;