Hi Bram,

2016/11/26 Sat 23:10:03 UTC+9 Bram Moolenaar wrote:
> Ken Takata wrote:
> 
> > 2016/11/25 Fri 1:23:12 UTC+9 Bram Moolenaar wrote:
> > > Patch 8.0.0097
> > > Problem:    When a channel callback consumes a lot of time Vim becomes
> > >             unresponsive. (skywind)
> > > Solution:   Bail out of checking channel readahead after 100 msec.
> > > Files:      src/os_unix.c, src/misc2.c, src/vim.h, src/os_win32.c
> > 
> > > +     long
> > > + elapsed(DWORD start_tick)
> > > + {
> > > +     DWORD       now = GetTickCount();
> > > + 
> > > +     if (now < start_tick)
> > > +         /* overflow */
> > > +         return (long)now;
> > > +     return (long)now - (long)start_tick;
> > > + }
> > 
> > I don't think overflow checking is needed here.
> > 
> >     return (long)now - (long)start_tick;
> > 
> > should work on Windows even if overflow occurs.
> 
> DWORD is 32 bits unsigned, right?  And long is 32 bits signed.

Right. So the following should work:

    long
elapsed(DWORD start_tick)
{
    DWORD       now = GetTickCount();

    return (long)now - (long)start_tick;
}

Or we can reduce a cast:

    return (long)(now - start_tick);


Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui