Proposal for Optimized Character Type Function

Florian Weimer fw@deneb.enyo.de
Sat Mar 1 21:19:22 GMT 2025


* The Cuthour:

> On 2025/03/02 5:15, Florian Weimer wrote:
>> * The Cuthour:
>> 
>>> I am writing to propose an enhancement to the character type functions
>>> such as isalpha(), isupper(), and islower() through the use of optimized
>>> lookup tables. By using a single lookup table with bitwise operations,
>>> we can achieve efficient and concise implementations for these
>>> functions. Below is a brief overview of the proposed implementation:
>> 
>> Isn't this basically what the current implementation does, via
>> __ctype_b_loc?  Per-thread state is required to support uselocale.
>
> I don't know. My plan is this.
>
> --------------------------------
>
> static const unsigned char type_table[256] = {
>      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

We already have such tables:

  <https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/C-ctype.c>


More information about the Libc-alpha mailing list