Re: [hackers] [dmenu] import new drw from libsl and minor fixes.

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Fri, 3 Jun 2016 18:55:36 +0200

Hiltjo Posthuma wrote:
> I noticed a regression, dmenu seems really slow to load on my machine in the
> function readstdin(). Was the font cache behaviour removed from drw?

Heyho,

that is probably because of the second change noted from readstdin():

> > - fix bug where inputw was not correctly calculated from the widest item,
> > but just from the one with the longest strlen() which is not the same.

I did not remove the caching, but if you look at this part of the dmenu diff,
there is now a call to TEXTW instead of just strlen:

> _AT_@ -482,12 +471,11 @@ readstdin(void)
> if (!(items[i].text = strdup(buf)))
> die("cannot strdup %u bytes:", strlen(buf) + 1);
> items[i].out = 0;
> - if (strlen(items[i].text) > max)
> - max = strlen(maxstr = items[i].text);
> + if (inputw < (tmpmax = TEXTW(items[i].text)))
> + inputw = tmpmax;
> }
> if (items)
> items[i].text = NULL;
> - inputw = maxstr ? TEXTW(maxstr) : 0;
> lines = MIN(lines, i);
> }

I don't see how your patch fixes the slowness, since it still calculates the
actual width of every item in readstdin(). It only caches the value for later
use, but as I understand, there is no problem later on. I tested
drw_font_getexts instead of TEXTW, which seems to be a lot faster, but is not as
accurate, since it doesn't account for fallback fonts if they are needed in the
string. Please try the attached dmenu patch and let me know if the slowness
problem is fixed.

--Markus

Received on Fri Jun 03 2016 - 18:55:36 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 03 2016 - 19:00:16 CEST