avoid redraw when there's no change 6818e072
while i was timing the performance issue, i noticed that there was lots
of random redrawing going on.

turns out there were coming from here; if someone presses CTRL/ALT etc
without pressing anything else, nothing will be inserted, so nothing
will change. but the code will `break`, go down and do a needless redraw.

this patch changes it to simply return if the keypress iscntrl()

also avoid potential UB by casting *buf into an unsigned char.
NRK · 2022-03-25 22:51 1 file(s) · +3 −2
dmenu.c +3 −2
415 415
	switch(ksym) {
416 416
	default:
417 417
insert:
418 -
		if (!iscntrl(*buf))
419 -
			insert(buf, len);
418 +
		if (iscntrl((unsigned char)*buf))
419 +
			return;
420 +
		insert(buf, len);
420 421
		break;
421 422
	case XK_Delete:
422 423
	case XK_KP_Delete: