From: Duy Nguyen Date: Wed, 16 Jan 2013 03:12:16 GMT Subject: Re: [PATCH] attr: fix off-by-one directory component length calculation Message-ID: In-Reply-To: <7vbocp26xa.fsf@alter.siamese.dyndns.org> On Wed, Jan 16, 2013 at 9:33 AM, Junio C Hamano wrote: > Duy Nguyen 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