Hello Alejandro!

Alejandro Colomar wrote in
 <aZeGabzZUpS4fT4B@devuan>:
 |On 2026-02-19T22:15:29+0100, Steffen Nurpmeso wrote:
 |> Crystal Kolipe via Mutt-dev wrote in
 |>  <[email protected]>:
 |>|On Thu, Feb 19, 2026 at 02:32:45PM +0100, Alejandro Colomar via Mutt-dev \
 |>|\
 |>|wrote:
 |> 
 |> I think "the best" is a table lookup.
 |> I use the below script to create a lookup table, it is easily
 |> adaptable (it is 128 bytes + alignment, and it could be like this
 |> ASM looks even better, all in all.
 |
 |By "best" are you optimizing for performance or readability?  I prefer
 |readability any day.  We're not libc nor cc(1); we don't need to
 |have the absolute best performance, or we'd be writing assembly (this is
 |what glibc does, indeed).  We can get 80% of the juice with trivial
 |one-liners that get optimized by the compiler and libc.

You were talking assembly!  But i am too, yes, i mean x86 has
an explicit XLAT instruction, for example (never used it).
In general with a constant single-instance lookup table and
all-inlined accessors of that, .. of course the table is to be
located relatively to the global offset table, but no "call" at
all, could turn out as maybe even two instructions ("test(b) bit,
mem", plus whatever then comes).
If you make the table 256 bytes you can even scratch "is-7-bit"
check and simply do table[(u8)..char..] & BIT1[|BIT2..].
(Ie, that is the other nice thing, you could test certain things
with one lookup, ie space|punct|alnum, or whatever.)

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

Reply via email to