aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-05-25 09:39:46 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-05-25 09:39:46 +0000
commit9b2f98d2feae5200d6354826eefe98084a3df476 (patch)
treea3370b02a03a2aa226c6cd6824b09a6c4193a2a8 /src
parentf8b240d7dbaf90cf9d53df0a82153ed731918c29 (diff)
speeding things up significantly when handling looong FIFOs by storing both the first(=read) and the last(=write) entry
svn path=/trunk/externals/zexy/; revision=3086
Diffstat (limited to 'src')
-rw-r--r--src/fifop.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/fifop.c b/src/fifop.c
index f246bfc..82d6d41 100644
--- a/src/fifop.c
+++ b/src/fifop.c
@@ -42,6 +42,7 @@ typedef struct _fifop_list {
typedef struct _fifop_prioritylist {
t_float priority;
t_fifop_list *fifo_start;
+ t_fifop_list *fifo_end;
struct _fifop_prioritylist *next;
} t_fifop_prioritylist;
@@ -78,13 +79,14 @@ static t_fifop_prioritylist*fifop_genprioritylist(t_fifop*x, t_float priority)
result = (t_fifop_prioritylist*)getbytes(sizeof( t_fifop_prioritylist));
result->priority=priority;
result->fifo_start=0;
+ result->fifo_end=0;
result->next=0;
/* insert it into the list of priority lists */
if(dummy==0){
/* insert at the beginning */
result->next=x->fifo_list;
- x->fifo_list=result;
+ x->fifo_list=result;
} else {
/* post insert into the list of FIFOs */
result->next=dummy->next;
@@ -120,15 +122,19 @@ static int add2fifo(t_fifop_prioritylist*fifoprio, int argc, t_atom *argv)
entry->argc=argc;
entry->next=0;
- /* go to end of fifo */
- fifo=fifoprio->fifo_start;
- if(fifo){
- while(fifo->next!=0)fifo=fifo->next;
+ /* insert entry into fifo */
+ if(fifoprio->fifo_end){
+ /* append to the end of the fifo */
+ fifo=fifoprio->fifo_end;
+
/* add new entry to end of fifo */
fifo->next=entry;
+ fifoprio->fifo_end=entry;
} else {
/* the new entry is the 1st entry of the fifo */
fifoprio->fifo_start=entry;
+ /* and at the same time, it is the last entry */
+ fifoprio->fifo_end =entry;
}
}
static t_fifop_prioritylist*getFifo(t_fifop_prioritylist*pfifo)
@@ -163,7 +169,9 @@ static void fifop_bang(t_fifop *x)
}
pfifo->fifo_start=fifo->next;
-
+ if(0==pfifo->fifo_start){
+ pfifo->fifo_end=0;
+ }
/* get the list from the entry */
argc=fifo->argc;
argv=fifo->argv;
@@ -203,6 +211,7 @@ static void fifop_free(t_fifop *x)
}
fifo_list2->priority =0;
fifo_list2->fifo_start=0;
+ fifo_list2->fifo_end =0;
fifo_list2->next =0;
freebytes(fifo_list2, sizeof( t_fifop_prioritylist));
}