[dev] reusable lib for suckless packages

From: Nikita Zlobin <nick87720z_AT_gmail.com>
Date: Sun, 4 Jul 2021 13:15:08 +0500

I found, some files are common between different s* packages.
E.g., I sent cleaned up arg.h for tabbed and st, but it's still in more
places, like dmenu.

Would be more wise to move these files, as well as some functions, to
system-installed libs. Headers would go to include dir, and reusable
code could be in libdir, as static libs. Should not note, everything
must be built with same compiler (kkk, just did it).

Imho, it's not necessary for reusable code to be enough big as long as
redundant size is against principles for all the project.

For code example - I discovered interesting hex2int() implementation in
qsampler code while fixed utf8 support in lscp communication (it's used
in unescaping functions, converting incoming escapes to bytes). This
implementation uses dumbest approach - switch(), comparing with each
hex value in range instead of smart/compact approaches. My minimal test
took ≈4sec with smart approaches, while dumb switch() approach took
only ≈0.5. Of course, I did not yet test conversion for long hex
numbers - in qsampler that variant was used only for single bytes, i.e.
=2 hex chars, not more or less.

My rule here is simple - if same code is used in many places, than
place it to lib (of course, I can cound more than up to 3 XD).
Rather adapted rule from C++: if you have common function in many
places, make a class for it.

In my vision this lib should have same place in suckless project as
glibc in all linux. At least complement it (like boost for stdc++,
though incredibly better). Could be named like 'slib'.
Received on Sun Jul 04 2021 - 10:15:08 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 04 2021 - 19:00:07 CEST