Re: [hackers] [st][PATCH] Rearrange x run with fast exit
On Wed, Mar 18, 2020 at 02:10:36PM +0100, Quentin Rameau wrote: >> Quickly swap out of loop to reduce indentation needed. >> Reuse deltatime variable to reuse calculation. > >Don't be afraid to separate unrelated modifications into separate >commits! > On Wed, Mar 18, 2020 at 09:41:14PM +0100, Quentin Rameau wrote: I separate unrelated modifications into unrelated commits but this is still related, I think it also belongs under reorderings. That was the polite way of saying “They're unrelated, separate them in two commits”, apparently polite messages don't convey the meaning. Ah, I thought it was just telling me that it is possible to separate unrelated modifications but I already know that. I will send a patch. Thanks.
Re: [hackers] [st][PATCH] Rearrange x run with fast exit
> I separate unrelated modifications into unrelated commits but this is > still related, I think it also belongs under reorderings. That was the polite way of saying “They're unrelated, separate them in two commits”, apparently polite messages don't convey the meaning. > On Wed, Mar 18, 2020 at 02:10:36PM +0100, Quentin Rameau wrote: > >> Quickly swap out of loop to reduce indentation needed. > >> Reuse deltatime variable to reuse calculation. > > > >Don't be afraid to separate unrelated modifications into separate > >commits! > > >
Re: [hackers] [st][PATCH] Rearrange x run with fast exit
I separate unrelated modifications into unrelated commits but this is still related, I think it also belongs under reorderings. On Wed, Mar 18, 2020 at 02:10:36PM +0100, Quentin Rameau wrote: Quickly swap out of loop to reduce indentation needed. Reuse deltatime variable to reuse calculation. Don't be afraid to separate unrelated modifications into separate commits!
Re: [hackers] [st][PATCH] Rearrange x run with fast exit
> Quickly swap out of loop to reduce indentation needed. > Reuse deltatime variable to reuse calculation. Don't be afraid to separate unrelated modifications into separate commits!
[hackers] [st][PATCH] Rearrange x run with fast exit
Quickly swap out of loop to reduce indentation needed. Reuse deltatime variable to reuse calculation. --- x.c | 56 +--- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/x.c b/x.c index 48a6676..01fd62a 100644 --- a/x.c +++ b/x.c @@ -1915,41 +1915,35 @@ run(void) } deltatime = TIMEDIFF(now, last); if (deltatime > 1000 / (xev ? xfps : actionfps)) { - dodraw = 1; last = now; + dodraw = 1; } - if (dodraw) { - while (XPending(xw.dpy)) { - XNextEvent(xw.dpy, &ev); - if (XFilterEvent(&ev, None)) - continue; - if (handler[ev.type]) - (handler[ev.type])(&ev); - } + if (!dodraw) + continue; + while (XPending(xw.dpy)) { + XNextEvent(xw.dpy, &ev); + if (XFilterEvent(&ev, None)) + continue; + if (handler[ev.type]) + (handler[ev.type])(&ev); + } - draw(); - XFlush(xw.dpy); - - if (xev && !FD_ISSET(xfd, &rfd)) - xev--; - if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) { - if (blinkset) { - if (TIMEDIFF(now, lastblink) \ - > blinktimeout) { - drawtimeout.tv_nsec = 1000; - } else { - drawtimeout.tv_nsec = (1E6 * \ - (blinktimeout - \ - TIMEDIFF(now, - lastblink))); - } - drawtimeout.tv_sec = \ - drawtimeout.tv_nsec / 1E9; - drawtimeout.tv_nsec %= (long)1E9; - } else { - tv = NULL; - } + draw(); + XFlush(xw.dpy); + + if (xev && !FD_ISSET(xfd, &rfd)) + xev--; + if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) { + if (blinkset) { + deltatime = TIMEDIFF(now, lastblink); + drawtimeout.tv_nsec = deltatime > blinktimeout + ? 1000 + : 1E6 * (blinktimeout - deltatime); + drawtimeout.tv_sec = drawtimeout.tv_nsec / 1E9; + drawtimeout.tv_nsec %= (long)1E9; + } else { + tv = NULL; } } } -- 2.25.1