From 8a32c75138d8431475b6bcd23c1d35b1386d1ae1 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 30 Jun 2013 12:48:37 +0200 Subject: [PATCH] CKTfndDev(), #5/6, cleanup --- src/spicelib/devices/cktfinddev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/spicelib/devices/cktfinddev.c b/src/spicelib/devices/cktfinddev.c index f6da1ea82..89e99c9f2 100644 --- a/src/spicelib/devices/cktfinddev.c +++ b/src/spicelib/devices/cktfinddev.c @@ -27,15 +27,15 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel * GENinstance *here; GENmodel *mods; + /* we know the device instance `fast' */ if (fast && *fast) { - /* already have fast, so nothing much to do just get & set type */ if (type) *type = (*fast)->GENmodPtr->GENmodType; return OK; } + /* we know the model `modfast', but need to find the device instance */ if (modfast) { - /* have model, just need device */ mods = modfast; here = find_instance(mods->GENinstances, name); if (here) { @@ -50,8 +50,8 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel * return E_NODEV; } + /* we know device `type', but need to find model and device instance */ if (*type >= 0 && *type < DEVmaxnum) { - /* have device type, need to find model & device */ /* look through all models */ for (mods = ckt->CKThead[*type]; mods ; mods = mods->GENnextModel) { /* and all instances */ @@ -69,10 +69,9 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel * return E_NOMOD; } + /* we don't even know `type', search all of them */ if (*type == -1) { - /* look through all types (UGH - worst case - take forever) */ for (*type = 0; *type < DEVmaxnum; (*type)++) { - /* need to find model & device */ /* look through all models */ for (mods = ckt->CKThead[*type]; mods; mods = mods->GENnextModel) { /* and all instances */