Re: [PATCH 5/5] tree-walk: match_entry microoptimization
- From
Dan McGee <dpmcgee@gmail.com>
- Date
- Apr 2, 2011, 17:54 UTC
- Message-ID
- <BANLkTinMoSBhG2d=JDhR5homsgn=_HB87w@mail.gmail.com>
- In-Reply-To
- <BANLkTikZ=eH-Jdd-kdvw4JKPbqCr7kviZg@mail.gmail.com>
On Sat, Apr 2, 2011 at 4:06 AM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 8 quoted lines
> On Thu, Mar 31, 2011 at 8:38 AM, Dan McGee <dpmcgee@gmail.com> wrote: >> Before calling strncmp(), see if we can get away with checking only the >> first character of the passed path components instead. >> >> Signed-off-by: Dan McGee <dpmcgee@gmail.com> > > I wonder if inlining strcmp() would be better (at least cleaner code). > It seems like you try to avoid the function call cost here.
100% agree with you, but I have no idea how to do that. Realize also you can use memcmp() here; I tried that and got no noticeable gain (likely due to how short these strings are). However, it is what we use in most other functions in this file. I assume the compiler would inline versions with a static length, but if you have suggestions as to how to inline a non-trivial version here I'm all ears.
-Dan