From 201f4c729bbb86f8933c2d520e018fb9c3808377 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 7 Sep 2022 17:27:49 -0700 Subject: [PATCH] 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. --- lib/dotgen/dotsplines.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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; -- 2.50.1