Re: [hackers] Re: [dmenu][patch] Improve speed of drw_text when provided with large strings

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 26 Dec 2021 19:29:27 +0100

On Mon, Aug 09, 2021 at 06:35:57PM +0200, Hiltjo Posthuma wrote:
> On Sat, Aug 07, 2021 at 09:39:44PM -0400, Miles Alan wrote:
> > On Sat, Aug 7, 2021, at 9:34 PM, m_AT_milesalan.com wrote:
> > > - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
> > > - drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
> > > + if (ew > w)
> > > + for (ew = 0, len = 0; ew < w - lpad * 2 && len < MIN(utf8strlen,
> > > sizeof(buf) - 1); len++)
> > > + drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
> > > + else
> > > + len = MIN(utf8strlen, sizeof(buf) - 1);
> >
> > To test, try selecting previous/next items with the following (adjust -c as needed):
> > for i in $(seq 20); do
> > cat /dev/urandom | base64 | tr -d '\n' | head -c 1000000
> > done | ./dmenu -l 10
> >
>
> Hi Miles,
>
> Thanks for the patch. It uses indeed less resources for very long lines and it
> makes more sense to do it this way.
>
> A small change for the test script, you probably want to add a newline (echo)
> between it:
>
> for i in $(seq 20); do
> cat /dev/urandom | base64 | tr -d '\n' | head -c 1000000
> echo
> done | ./dmenu -l 10
>
> I synced the code to dwm and the libsl repository too.
>
> --
> Kind regards,
> Hiltjo
>

Hi,

This patch had issues so it was reverted for now. Anyone have time to work on
this during the holidays maybe?

The drw.c drw_text() text truncation code using "..." is also incorrect
currently for UTF-8 and when multiple fallback fonts are used.

-- 
Kind regards,
Hiltjo
Received on Sun Dec 26 2021 - 19:29:27 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 26 2021 - 19:36:30 CET