From bfb01e032f668c09ff43e889f35d611ef0e4a317 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sun, 16 Jan 2022 14:47:52 -0500 Subject: [PATCH] Implemented another change discussed in netgen github issue #47 by Anton Blanchard, which prevents the double-loop in the PropertyOptimize() routine from continuing the outer loop if all devices in the run have already been merged. --- base/netcmp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/netcmp.c b/base/netcmp.c index db59c8f..3d6324e 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -4921,6 +4921,7 @@ int PropertyOptimize(struct objlist *ob, struct nlist *tp, int run, int series, // Now combine records with same properties by summing M (S). if (comb == FALSE) { for (i = 0; i < run - 1; i++) { + int nr_empty = 0; for (j = i + 1; j < run; j++) { pmatch = 0; for (p = 1; p < pcount; p++) { @@ -5044,8 +5045,14 @@ int PropertyOptimize(struct objlist *ob, struct nlist *tp, int run, int series, vlist[0][i]->value.ival += vlist[0][j]->value.ival; vlist[0][j]->value.ival = 0; } + else + nr_empty++; } } + // If everything from i to the end of the run has been matched + // and zeroed out, then nothing more can be merged. + if (nr_empty == (run - (i + 1))) + break; } }