Skip to content

Commit

Permalink
selector/poll: some speed improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Jul 19, 2012
1 parent 7f82e75 commit 9a30499
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions nucular/selector/poll.d
Expand Up @@ -51,11 +51,8 @@ class Selector : base.Selector

pollfd p = { fd: descriptor.to!int };

_set.length++;

_set[$ - 1] = _set[$ - 2];
_set[$ - 2] = p;
_last = null;
_set ~= p;
_last = null;

return true;
}
Expand Down Expand Up @@ -124,7 +121,7 @@ class Selector : base.Selector
return;
}

foreach (ref p; _set[0 .. $ - 1]) {
foreach (ref p; _set[1 .. $]) {
static if (mode == "both") {
p.events = POLLIN | POLLOUT;
}
Expand All @@ -144,7 +141,7 @@ class Selector : base.Selector
{
Descriptor[] result;

foreach (index, ref p; _set[0 .. $ - 1]) {
foreach (index, ref p; _set[1 .. $]) {
static if (mode == "read") {
if (p.revents & POLLIN) {
result ~= descriptors[index];
Expand Down

0 comments on commit 9a30499

Please sign in to comment.