From bdf6091da7ead23c52cb507f73ad93bfc4370cee Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 10 Jan 2018 17:08:57 +0100 Subject: [PATCH] parser/inpgmod.c, #6/6, cleanup, introduce find_model_parameter() --- src/spicelib/parser/inpgmod.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index 79f6b3881..b2c158a58 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -34,6 +34,20 @@ static int INPfindParm(char *name, IFparm *table, int numParms); extern INPmodel *modtab; +static IFparm * +find_model_parameter(const char *name, IFdevice *device) +{ + IFparm *p = device->modelParms; + IFparm *p_end = p + *(device->numModelParms); + + for (; p < p_end; p++) + if (strcmp(name, p->keyword) == 0) + return p; + + return NULL; +} + + /* * code moved from INPgetMod */ @@ -86,15 +100,9 @@ create_model(CKTcircuit *ckt, INPmodel *modtmp, INPtables *tab) continue; } - IFparm *p = device->modelParms; - IFparm *p_end = p + *(device->numModelParms); + IFparm *p = find_model_parameter(parm, device); - for (; p < p_end; p++) { - if (strcmp(parm, p->keyword) == 0) - break; - } - - if (p < p_end) { + if (p) { IFvalue *val = INPgetValue(ckt, &line, p->dataType, tab); error = ft_sim->setModelParm(ckt, modtmp->INPmodfast, p->id, val, NULL); if (error)