From 771d1fa6972cce3cc4c9fe58a5e06cadd71f94bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Forst=C3=A9n?= Date: Wed, 17 Jul 2013 20:24:43 +0200 Subject: [PATCH] CKTfndDev(), rewrite --- src/spicelib/devices/cktfinddev.c | 60 ++++++------------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/src/spicelib/devices/cktfinddev.c b/src/spicelib/devices/cktfinddev.c index 4e423cf95..cb493f537 100644 --- a/src/spicelib/devices/cktfinddev.c +++ b/src/spicelib/devices/cktfinddev.c @@ -14,7 +14,6 @@ int CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast) { GENinstance *here; - GENmodel *mods; /* we know the device instance `fast' */ if (fast && *fast) { @@ -23,57 +22,18 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel * return OK; } - /* we know the model `modfast', but need to find the device instance */ - if (modfast) { - here = nghash_find(ckt->DEVnameHash, name); - if (here && here->GENmodPtr == modfast) { - if (fast) - *fast = here; + here = nghash_find(ckt->DEVnameHash, name); - if (type) - *type = modfast->GENmodType; + if (here) { - return OK; - } - return E_NODEV; + if (fast) + *fast = here; + + if (type) + *type = here->GENmodPtr->GENmodType; + + return OK; } - /* we know device `type', but need to find model and device instance */ - if (*type >= 0 && *type < DEVmaxnum) { - /* look through all models */ - for (mods = ckt->CKThead[*type]; mods ; mods = mods->GENnextModel) { - /* and all instances */ - here = nghash_find(ckt->DEVnameHash, name); - if (here && here->GENmodPtr == mods) { - if (fast) - *fast = here; - return OK; - } - if (mods->GENmodName == NULL) - return E_NODEV; - } - return E_NOMOD; - } - - /* we don't even know `type', search all of them */ - if (*type == -1) { - for (*type = 0; *type < DEVmaxnum; (*type)++) { - /* look through all models */ - for (mods = ckt->CKThead[*type]; mods; mods = mods->GENnextModel) { - /* and all instances */ - here = nghash_find(ckt->DEVnameHash, name); - if (here && here->GENmodPtr == mods) { - if (fast) - *fast = here; - return OK; - } - if (mods->GENmodName == NULL) - return E_NODEV; - } - } - *type = -1; - return E_NODEV; - } - - return E_BADPARM; + return E_NODEV; }