[Libevent-users] [PATCH] Do not call gettime in timeout_process if
the timetree is empty
Trond Norbye
Trond.Norbye at Sun.COM
Thu Sep 20 09:14:51 EDT 2007
Christopher Layne wrote:
>
>> Index: event.c
>> ===================================================================
>> --- event.c (revision 440)
>> +++ event.c (working copy)
>> @@ -804,24 +804,26 @@
>> void
>> timeout_process(struct event_base *base)
>> {
>> - struct timeval now;
>> - struct event *ev, *next;
>> + if (!RB_EMPTY(&base->timetree)) {
>> + struct timeval now;
>> + struct event *ev, *next;
>>
>
> Why not just return if RB_EMPTY() is true rather than adding another level
> of indention?
Some people (I'm not one of them) dislikes multiple return statements
from a function, so I just added the extra level to avoid annoying them ;-)
> Other than that, I also noticed this but didn't consider it as
> anything significant. It has never once showed up as any significant source
> of cycles in profiling either.
>
I noticed that I had a huge number of calls to this function when I ran
"truss -c" a couple of seconds on my program, so I would like to reduce
the number of unnecessary context switches.
Trond
More information about the Libevent-users
mailing list