Drastically reduce the evaluation time of the lists.

Avoid scanning the list to find the last element.
This commit is contained in:
Holger Vogt 2024-10-16 17:09:49 +02:00
parent 36be7a4f75
commit b76376a6bc
4 changed files with 22 additions and 23 deletions

View File

@ -12,23 +12,22 @@ listInsert (BSIM4vgsList **list, double vgs)
{
BSIM4vgsList *current, *previous ;
/* Loop until the end of the list */
previous = NULL ;
current = *list ;
while (current != NULL)
{
previous = current ;
current = current->next ;
}
/* create a new 'list' or add an element.
'last' contains the address of the last element */
if (*list)
previous = (*list)->last;
else
previous = NULL;
/* Insert the new element into the list */
if (previous == NULL)
{
*list = TMALLOC (BSIM4vgsList, 1) ;
current = *list ;
} else {
current = TMALLOC (BSIM4vgsList, 1) ;
previous->next = current ;
*list = TMALLOC(BSIM4vgsList, 1);
(*list)->last = current = *list;
}
else {
current = TMALLOC(BSIM4vgsList, 1);
(*list)->last = previous->next = current;
}
/* Populate the element */

View File

@ -35,6 +35,7 @@ Modified by Pankaj Kumar Thakur, 07/23/2012
typedef struct sBSIM4vgsList {
double vgs ;
struct sBSIM4vgsList *next ;
struct sBSIM4vgsList *last ;
} BSIM4vgsList ;
#endif

View File

@ -19,23 +19,21 @@ listInsert (RELMODELrelList **list, double time, double deltaVth)
RELMODELrelList *current ;
RELMODELrelList *previous ;
/* Loop until the end of the list */
previous = NULL ;
current = *list ;
while (current != NULL)
{
previous = current ;
current = current->next ;
}
/* create a new 'list' or add an element.
'last' contains the address of the last element */
if (*list)
previous = (*list)->last;
else
previous = NULL;
/* Insert the new element into the list */
if (previous == NULL)
{
*list = TMALLOC (RELMODELrelList, 1) ;
current = *list ;
(*list)->last = current = *list ;
} else {
current = TMALLOC (RELMODELrelList, 1) ;
previous->next = current ;
(*list)->last = previous->next = current ;
}
/* Populate the element */

View File

@ -15,6 +15,7 @@ typedef struct sRELMODELrelList {
double time ;
double deltaVth ;
struct sRELMODELrelList *next ;
struct sRELMODELrelList *last ;
} RELMODELrelList ;
typedef struct sRELMODELrelStruct {