Re: [PATCH] attr: fix off-by-one directory component length calculation
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 16, 2013, 03:12 UTC
- Message-ID
- <CACsJy8C2uEgwozpWBfowYJea3XRB72rhzjsSFuG9Ud0afuQy6w@mail.gmail.com>
- In-Reply-To
- <7vbocp26xa.fsf@alter.siamese.dyndns.org>
On Wed, Jan 16, 2013 at 9:33 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes: > >> On Wed, Jan 16, 2013 at 08:08:03AM +0700, Duy Nguyen wrote: >>> Actually I'd like to remove that function. >> >> This is what I had in mind: > > I think the replacement logic to find the basename is moderately > inferiour to the original. For one thing (this may be somewhat > subjective), it is less readable now.
Yeah, maybe it's micro optimization.
> Also the original only > scanned the string from the beginning once (instead of letting > strlen() to scan once and go back).
But we do need to strlen() anyway in collect_all_attrs(). So we scan the string 3 times (strlen + 2 * find_basename) in the original. Now we do it twice
-- Duy