From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH] dcache: faster dentry_cmp() Date: Tue, 14 Feb 2012 22:58:39 +0000 Message-ID: <20120214225839.GA23916@ZenIV.linux.org.uk> References: <20120214224526.GA3478@p183.telecom.by> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, npiggin@kernel.dk To: Alexey Dobriyan Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:43078 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932117Ab2BNW6n (ORCPT ); Tue, 14 Feb 2012 17:58:43 -0500 Content-Disposition: inline In-Reply-To: <20120214224526.GA3478@p183.telecom.by> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Feb 15, 2012 at 01:45:27AM +0300, Alexey Dobriyan wrote: > 1) consistently use "unsigned int" for dentry name length, > 2) reuse subtraction result for return value, exact value doesn't matter > because function is only used in boolean context, > 3) use *p++ idiom for even better code. > > All of this results in performance speedup of "git diff" > which is way out of statistical error (0.4% vs 0.15% of 3 sigma): > - if (scount != tcount) > - return 1; > + > + ret = scount - tcount; > + if (ret) > + return ret; > do { > - ret = (*cs != *ct); > + ret = *cs++ - *ct++; > if (ret) > break; > - cs++; > - ct++; > tcount--; > } while (tcount); > return ret; I wonder what'll happen if you simply replace that loop with return memcmp(cs, ct, tcount); which is what it really is...