[PATCH] memmem.c, strstr.c: use unsigned int instead of size_t for small needles

Wilco Dijkstra Wilco.Dijkstra@arm.com
Fri Dec 15 14:46:32 GMT 2023


Hi James,

What is the goal of this patch? Is there a performance difference?
You should provide a clear description that explains the reasons
behind this patch and the benefits - without this, it is unlikely to be
accepted.

> +  typedef unsigned int Idx;

Why create a new typedef when we already have uint32_t?

> +  _Static_assert (sizeof (shift) / sizeof (shift[0]) == 256 && sizeof (shift[0]) <= sizeof (Idx), "Index type is too small.");

What is the point of this just a few lines below the definition of shift?
It's obvious that a 32-bit type will work - but what isn't obvious is why
you think that is better than using size_t.

Cheers,
Wilco


More information about the Libc-alpha mailing list