[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 22 of 22] Fixed inability to focus windows via mouse



 
> > +static int
> > +compareTimes(Time t1, Time t2)
> > +{
> > +    Time diff;
> > +    if (t1 == t2)
> > +      return 0;
> > +    diff = t1 - t2;
> > +    return (diff < 60000) ? 1 : -1;
> > +}
> 
> I think it is better to drop this function entirely and use the
> second version proposed by Pedro, where we avoid making a function call
> and the below is changed to
> 
> > -    if (scr->flags.ignore_focus_events || LastFocusChange > timestamp)
> > +    if (scr->flags.ignore_focus_events || compareTimes(LastFocusChange, timestamp) > 0)
>                                              (LastFocusChange - timestamp) < 60000


Ok, so gcc is smart enough to optimize those things anyway.

This is what I get here with the function call

     cmp    %rax,%r13
     je     1c0e <wSetFocusTo+0x5e>
     sub    %r13,%rax
     cmp    $0xea5f,%rax
     jbe    1d21 <wSetFocusTo+0x171>
     
and this is without it

     sub    %r13,%rax
     cmp    $0xea5f,%rax
     jbe    1d20 <wSetFocusTo+0x170>

The difference is the missing check for t1 == t2, which will never happen
in practice anyway.



-- 
To unsubscribe, send mail to wmaker-dev-unsubscribe@lists.windowmaker.info.