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

From: NRK <nrk_AT_disroot.org>
Date: Sun, 13 Mar 2022 16:35:55 +0600

On Sun, Dec 26, 2021 at 07:29:27PM +0100, Hiltjo Posthuma wrote:
> > 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.

Hi,

I assume the reason for this was that with loop condition `n < limit`
the loop would stop when `n >= limit`, meaning that n might
"over-shoot".

If that was the case, then just having another loop cleanup the
over-shoot should fix the issue. Testing with the test script in this
thread, I see proper truncation identical to mainline dmenu without this
patch.

However I still saw some problems with emojies/unicode truncation, the
test file is attached.

        ./dmenu < unicringe.txt

Changing the first loop condition from `len < MIN(..)` to `len <=
MIN(..)` fixes that as well for me.

NB: I'm not really sure weather this patch is *actually* correct or not.
But since both of my test-cases are passing, sending the patch.

- NRK

Received on Sun Mar 13 2022 - 11:35:55 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 13 2022 - 11:36:40 CET