On Thu, Mar 19, 2020 at 09:11:59AM +0800, Ivan Tham wrote:
> Quickly swap out of loop to reduce indentation.
> ---
>  x.c | 55 +++++++++++++++++++++++++++----------------------------
>  1 file changed, 27 insertions(+), 28 deletions(-)
> 
> diff --git a/x.c b/x.c
> index 48a6676..03f397f 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -1919,37 +1919,36 @@ run(void)
>  			last = now;
>  		}
>  
> -		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);
>  
> -			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;
> +		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 {
> -					tv = NULL;
> +					drawtimeout.tv_nsec = (1E6 * \
> +						(blinktimeout - \
> +						TIMEDIFF(now, lastblink)));
>  				}
> +				drawtimeout.tv_sec = \
> +					drawtimeout.tv_nsec / 1E9;
> +				drawtimeout.tv_nsec %= (long)1E9;
> +			} else {
> +				tv = NULL;
>  			}
>  		}
>  	}
> -- 
> 2.25.2
> 
> 
Hi Ivan,
The current version is more readable. I won't apply the patchset.
If there is an other reason for the refactoring or so, please say so.
Thanks,
-- 
Kind regards,
Hiltjo
Received on Thu Mar 19 2020 - 10:34:59 CET