Re: [PATCH v4 08/14] libfdt: Speed up fdt_find_string_len_() with memchr()

From: Doug Anderson

Date: Mon Nov 23 2026 - 19:38:11 EST


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?

-Doug