libdraw: make ebread() return buffer immidiately if available, cleanup
this reduces number of syscalls and improves performance for vt
This commit is contained in:
parent
62bd2ae8b9
commit
09d465a976
1 changed files with 6 additions and 16 deletions
|
@ -45,21 +45,10 @@ Ebuf*
|
||||||
ebread(Slave *s)
|
ebread(Slave *s)
|
||||||
{
|
{
|
||||||
Ebuf *eb;
|
Ebuf *eb;
|
||||||
Dir *d;
|
|
||||||
ulong l;
|
|
||||||
|
|
||||||
for(;;){
|
while((eb = s->head) == 0)
|
||||||
d = dirfstat(epipe[0]);
|
|
||||||
if(d == nil)
|
|
||||||
drawerror(display, "events: eread stat error");
|
|
||||||
l = d->length;
|
|
||||||
free(d);
|
|
||||||
if(s->head && l==0)
|
|
||||||
break;
|
|
||||||
extract();
|
extract();
|
||||||
}
|
s->head = eb->next;
|
||||||
eb = s->head;
|
|
||||||
s->head = s->head->next;
|
|
||||||
if(s->head == 0)
|
if(s->head == 0)
|
||||||
s->tail = 0;
|
s->tail = 0;
|
||||||
return eb;
|
return eb;
|
||||||
|
@ -322,9 +311,10 @@ loop:
|
||||||
memmove(eb->buf, &ebuf[1], n - 1);
|
memmove(eb->buf, &ebuf[1], n - 1);
|
||||||
eb->next = 0;
|
eb->next = 0;
|
||||||
if(s->head)
|
if(s->head)
|
||||||
s->tail = s->tail->next = eb;
|
s->tail->next = eb;
|
||||||
else
|
else
|
||||||
s->head = s->tail = eb;
|
s->head = eb;
|
||||||
|
s->tail = eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue