apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garrett Rooney <roo...@electricjellyfish.net>
Subject Re: UPDATE: [Patch] poll/unix/poll.c:apr_pollset_poll() optimisation
Date Thu, 05 Jan 2006 00:36:18 GMT
On 1/4/06, gerry@everythingsucks.co.uk <gerry@everythingsucks.co.uk> wrote:
> Greetings,
>
> There's a sneakier (and pretty obvious, once you look at it) way of
> improving this loop which I prefer to my original mail by replacing the
> for-loop condition.
>
> Should be safe: I like poll()... he has an honest face... I don't think
> he will lie to us about the number of signalled descriptors.
>
>
> --- poll.c      2006/01/02 18:30:27     1.1
> +++ poll.c      2006/01/05 00:11:36
> @@ -254,13 +254,13 @@
>          return apr_get_netos_error();
>      }
>      if (rv == 0) {
>          return APR_TIMEUP;
>      }
>      j = 0;
> -    for (i = 0; i < pollset->nelts; i++) {
> +    for (i = 0; j < rv; i++) {
>          if (pollset->pollset[i].revents != 0) {
>              pollset->result_set[j] = pollset->query_set[i];
>              pollset->result_set[j].rtnevents =
>                  get_revent(pollset->pollset[i].revents);
>              j++;
>          }
>

Um, I don't think that's going to work, rv is the number of
descriptors that hit, there's nothing that says that if N hit it'll be
the first N...

As for the other version of this patch, I'm kind of curious if it's an
actual improvement.  Sure, you can bail early, but at the cost of
intruducing an extra if into each of the iterations before you bail. 
Is that actually better in the average case?

-garrett

Mime
View raw message