Hi Branden, On Fri, Sep 19, 2025 at 02:56:31AM +0200, Alejandro Colomar wrote: > > > > wonder by how many orders of magnitude string (in)equality > > > > comparisons exceed string collation order comparisons. > > > > > > I have numbers in my laptop. I developed a patch for glibc adding > > > these APIs and then replacing every possible use within glibc itself. > > > When I use my laptop tomorrow, I can check the remaining strcmp() > > > calls compared to streq(). I remember having looked at the ratio, but > > > don't remember the numbers. I think it was in the hundreds of > > > equality calls per each sorting call. > > > > If you'd asked to me to bet, I'd have wagered at least 2 orders of > > magnitude, yeah. You probably could have bluffed me into 3. ;-) > > I think it's around 2.5. 3 would still be a fair guess.
Excluding strcmp(3) tests for obvious reasons, I count slightly under 50 legitimate uses of strcmp(3) in the entire glibc. On the other hand, I count slightly over 1000 uses of streq() (or strcmp(3)-as-streq()). This is actually just above 1 order of magnitude. It's a bit less pronounced than I remembered. Another data point is shadow utils. We have 1 legitimate call to strcmp(3), and slightly over 400 uses of streq(). That's around 2.5 orders of magnitude more. It depends on what the project does, but it seems to consistently be more than one order of magnitude. I'd be very surprised to see any project where the ratio is less than one order of magniture more common for streq(). Have a lovely day! Alex -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>).
signature.asc
Description: PGP signature