From: Matthew Fernandez Date: Mon, 13 Dec 2021 02:07:24 +0000 (-0800) Subject: makeStraightEdge: remove array allocation optimization X-Git-Tag: 3.0.0~126^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12ed787c61b5824d4fc707b0acc0b99d4be57042;p=graphviz makeStraightEdge: remove array allocation optimization This code had two alternative paths, one that used a heap-allocated array for edge counts above 20 and one that used a stack-allocated array for edge counts of 20 or less. The latter was an optimization to avoid heap allocation for smaller graphs. Modern dynamic allocators are fast enough that this kind of optimization is no longer relevant. --- diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 67b107da1..684ca8b62 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -1092,31 +1092,24 @@ static void bend(pointf spl[4], pointf centroid) * * FIX: handle ports on boundary? */ -#define MAX_EDGE 20 void makeStraightEdge(graph_t * g, edge_t * e, int et, splineInfo* sinfo) { edge_t *e0; - edge_t** edges; - edge_t* elist[MAX_EDGE]; int i, e_cnt; e_cnt = 1; e0 = e; while (e0 != ED_to_virt(e0) && (e0 = ED_to_virt(e0))) e_cnt++; - if (e_cnt <= MAX_EDGE) - edges = elist; - else - edges = N_NEW(e_cnt,edge_t*); + edge_t **edges = N_NEW(e_cnt, edge_t*); e0 = e; for (i = 0; i < e_cnt; i++) { edges[i] = e0; e0 = ED_to_virt(e0); } makeStraightEdges (g, edges, e_cnt, et, sinfo); - if (e_cnt > MAX_EDGE) free (edges); - + free(edges); } void