From: NRK Date: Wed, 23 Mar 2022 20:00:00 +0000 (+0600) Subject: introduce drw_fontset_getwidth_clamp() X-Git-Url: https://git.xinqibao.xyz/dmenu.git/commitdiff_plain/6be057f060543bb0f3ed9423904263617cdffffe?ds=inline;hp=6be057f060543bb0f3ed9423904263617cdffffe introduce drw_fontset_getwidth_clamp() getting the width of a string is an O(n) operation, and in many cases users only care about getting the width upto a certain number. instead of calling drw_fontset_getwidth() and *then* clamping the result, this patch introduces drw_fontset_getwidth_clamp() function, similar to strnlen(), which will stop once we reach n. the `invert` parameter was overloaded internally to preserve the API, however library users should be calling drw_fontset_getwidth_clamp() and not depend upon internal behavior of drw_text(). ---