From 84b429792d4b5fbd8e67c04576d145dd16c655fc Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 7 Sep 2022 17:02:36 -0400 Subject: [PATCH] Modified the cell copy routine so that it does not attempt to guarantee unique instance names during generation of each new copy, but only afterward, in bulk. Otherwise the copy routine has a runtime that is exponential with the number of cells being copied. This and the last commit guarantee that the "flatten -novendor" option works as advertised. --- database/DBcellcopy.c | 17 ++++++++--------- database/DBcellname.c | 13 +++++++++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/database/DBcellcopy.c b/database/DBcellcopy.c index f8f147cf..e7d130d9 100644 --- a/database/DBcellcopy.c +++ b/database/DBcellcopy.c @@ -1209,6 +1209,10 @@ DBCellCopyAllCells(scx, xMask, targetUse, pArea) GeoTransRect(&scx->scx_trans, &scx->scx_area, &arg.caa_rect); (void) DBTreeSrCells(scx, xMask, dbCellCopyCellsFunc, (ClientData) &arg); + + /* dbCellCopyCellsFunc() allows cells to be left with duplicate IDs */ + /* so generate unique IDs as needed now. */ + DBGenerateUniqueIds(targetUse->cu_def, FALSE); } /* @@ -1306,17 +1310,12 @@ dbCellCopyCellsFunc(scx, arg) return 2; } - /* When creating a new use, try to re-use the id from the old - * one. Only create a new one if the old id can't be used. - */ + /* When creating a new use, re-use the id from the old one. */ + /* Do not attempt to run DBLinkCell() now and resolve unique IDs; */ + /* just create duplicate IDs and regenerate unique ones at the end. */ newUse = DBCellNewUse(def, (char *) use->cu_id); - if (!DBLinkCell(newUse, arg->caa_targetUse->cu_def)) - { - freeMagic((char *) newUse->cu_id); - newUse->cu_id = NULL; - (void) DBLinkCell(newUse, arg->caa_targetUse->cu_def); - } + newUse->cu_expandMask = use->cu_expandMask; newUse->cu_flags = use->cu_flags; diff --git a/database/DBcellname.c b/database/DBcellname.c index 72d4b8b5..944c6a60 100644 --- a/database/DBcellname.c +++ b/database/DBcellname.c @@ -2098,6 +2098,14 @@ DBCellSrDefs(pattern, func, cdata) * This operation is not recorded on the undo list, as it always accompanies * the creation of a new cell use. * + * *** ANOTHER WARNING *** + * + * Do NOT pass a NULL cu_id to this routine when doing bulk cell copies, + * because an entire hash table of entries for the parent def will be created + * and searched for every cell being linked, making the routine run-time + * exponential with the number of links. It is better to run + * DBGenerateUniqueIDs() instead. + * * Results: * TRUE if the CellUse is unique within the parent CellDef, FALSE * if there would be a name conflict. If the cu_id of the CellUse @@ -2363,8 +2371,9 @@ dbFindNamesFunc(use, parentDef) he = HashFind(&dbUniqueNameTable, use->cu_id); if (HashGetValue(he)) { - TxError("Duplicate instance-id for cell %s (%s) will be renamed\n", - use->cu_def->cd_name, use->cu_id); + if (dbWarnUniqueIds) + TxError("Duplicate instance-id for cell %s (%s) will be renamed\n", + use->cu_def->cd_name, use->cu_id); DBUnLinkCell(use, parentDef); freeMagic(use->cu_id); use->cu_id = (char *) NULL;