Re: [PATCH v4 08/14] libfdt: Speed up fdt_find_string_len_() with memchr()
From: David Gibson
Date: Mon Nov 23 2026 - 22:02:53 EST
On Mon, Nov 23, 2026 at 04:37:51PM -0800, Doug Anderson wrote:
> David,
>
> On Mon, Nov 23, 2026 at 4:27 PM David Gibson
> <david@xxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > > > Fwiw, since this further optimization is essentially free in terms of
> > > > code complexity, I'm certainly happy to apply it. I am absolutely not
> > > > keen on further micro-optimization of this.
> > >
> > > OK, fair. Do you want me to drop the 1-line patch from my v5 draft
> > > then? It's basically this:
> > >
> > > - if (memcmp(p, s, slen) == 0 && p[slen] == '\0')
> > > + if (p[slen] == '\0' && memcmp(p, s, slen) == 0)
> > >
> > > While it is a micro-optimization, the code is no harder to read so it
> > > feels like a nice free speedup. ...but fine to drop it, too. ;-)
> >
> > Sorry, I was a bit unclear. Keep that change (though fold rather than
> > a separate patch, I'd suggest). As you say it doesn't hurt readability
> > at all.
>
> I don't think I can "fold" because you (the correct "you" this time!)
> already applied the patch I'd fold it into. I think it has to be a
> separate patch at this point, doesn't it?
Oh, yes, of course. Sorry.
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature