CKTfndDev(), use a hashtable to speed up this function
This commit is contained in:
parent
7911ed9eb9
commit
b96be8d576
|
|
@ -30,6 +30,7 @@
|
|||
#include "ngspice/sen2defs.h"
|
||||
#include "ngspice/pzdefs.h"
|
||||
#include "ngspice/noisedef.h"
|
||||
#include "ngspice/hash.h"
|
||||
|
||||
|
||||
|
||||
|
|
@ -281,6 +282,8 @@ struct CKTcircuit {
|
|||
contains only linear elements */
|
||||
unsigned int CKTnoopac:1; /* flag to indicate that OP will not be evaluated
|
||||
during AC simulation */
|
||||
|
||||
NGHASHPTR DEVnameHash;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ CKTdestroy(CKTcircuit *ckt)
|
|||
FREE(ckt->evt);
|
||||
#endif
|
||||
|
||||
nghash_free(ckt->DEVnameHash, NULL, NULL);
|
||||
FREE(ckt);
|
||||
return(OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ CKTcrtElt(CKTcircuit *ckt, GENmodel *modPtr, GENinstance **inInstPtr, IFuid name
|
|||
|
||||
modPtr->GENinstances = instPtr;
|
||||
|
||||
nghash_insert(ckt->DEVnameHash, name, instPtr);
|
||||
|
||||
if(inInstPtr != NULL)
|
||||
*inInstPtr = instPtr;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,17 +10,6 @@ Author: 1985 Thomas L. Quarles
|
|||
#include "string.h"
|
||||
|
||||
|
||||
static GENinstance *
|
||||
find_instance(GENinstance *here, IFuid name)
|
||||
{
|
||||
for (; here; here = here->GENnextInstance)
|
||||
if (here->GENname == name)
|
||||
return here;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast)
|
||||
{
|
||||
|
|
@ -36,8 +25,8 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *
|
|||
|
||||
/* we know the model `modfast', but need to find the device instance */
|
||||
if (modfast) {
|
||||
here = find_instance(modfast->GENinstances, name);
|
||||
if (here) {
|
||||
here = nghash_find(ckt->DEVnameHash, name);
|
||||
if (here && here->GENmodPtr == modfast) {
|
||||
if (fast)
|
||||
*fast = here;
|
||||
|
||||
|
|
@ -54,8 +43,8 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *
|
|||
/* look through all models */
|
||||
for (mods = ckt->CKThead[*type]; mods ; mods = mods->GENnextModel) {
|
||||
/* and all instances */
|
||||
here = find_instance(mods->GENinstances, name);
|
||||
if (here) {
|
||||
here = nghash_find(ckt->DEVnameHash, name);
|
||||
if (here && here->GENmodPtr == mods) {
|
||||
if (fast)
|
||||
*fast = here;
|
||||
return OK;
|
||||
|
|
@ -72,8 +61,8 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *
|
|||
/* look through all models */
|
||||
for (mods = ckt->CKThead[*type]; mods; mods = mods->GENnextModel) {
|
||||
/* and all instances */
|
||||
here = find_instance(mods->GENinstances, name);
|
||||
if (here) {
|
||||
here = nghash_find(ckt->DEVnameHash, name);
|
||||
if (here && here->GENmodPtr == mods) {
|
||||
if (fast)
|
||||
*fast = here;
|
||||
return OK;
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ CKTinit(CKTcircuit **ckt) /* new circuit to create */
|
|||
sckt->CKTabsDv = 0.5;
|
||||
sckt->CKTrelDv = 2.0;
|
||||
sckt->CKTvarHertz = 0;
|
||||
sckt->DEVnameHash = nghash_init_pointer(100);
|
||||
|
||||
#ifdef XSPICE
|
||||
/* gtri - begin - wbk - allocate/initialize substructs */
|
||||
|
|
|
|||
Loading…
Reference in New Issue