drw_text: improve performance when there's no match
authorNRK <nrk@disroot.org>
Wed, 23 Mar 2022 18:37:55 +0000 (00:37 +0600)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 25 Mar 2022 21:49:07 +0000 (22:49 +0100)
commit22511c41d55a38a770541ae617a09383d5e6ad1c
tree2239b8590d3bff0212ccf56e6f3c9fdcefcce5fe
parent77526f756e23e362081ac807521f901f2e5cd5e6
drw_text: improve performance when there's no match

this was the last piece of the puzzle, the case where we can't find any
font to draw the codepoint.

in such cases, we use XftFontMatch() which is INSANELY slow. but that's
not the real problem. the real problem was we were continuously trying
to match the same thing over and over again.

this patch introduces a small cache, which keeps track a couple
codepoints for which we know we won't find any matches.

with this, i can dump lots of emojies into dmenu where some of them
don't have any matching font, and still not have dmenu lag insanely or
FREEZE completely when scrolling up and down.

this also improves startup time, which will of course depend on the
system and all installed fonts; but on my system and test case i see the
following startup time drop:

before -> after
60ms   -> 34ms
drw.c