From: Dmitry Potapov Date: Fri, 01 May 2009 10:46:55 GMT Subject: Re: Why Git is so fast Message-ID: <20090501104655.GC4863@dpotapov.dyndns.org> In-Reply-To: <20090501094221.GB13264@glandium.org> On Fri, May 01, 2009 at 11:42:21AM +0200, Mike Hommey wrote: > On Fri, May 01, 2009 at 09:24:34AM +0400, Dmitry Potapov wrote: > > > > Good compilers can inline memcpy and should produce more efficient code > > for the target architecture, which can be faster than manually written. > > On x86_64, memcpy() requires only 3 load/store operations to copy SHA-1 > > while the above code requires 5 operations. > > I guess, though, that some enforced alignment could help produce > slightly more efficient code on some architectures (most notably sparc, > which really doesn't like to deal with unaligned words). Agreed. Enforcing good alignment may be useful. My point was that avoiding memcpy with modern compilers is rather pointless or even harmful because the compiler know more about the target architecture than the author of the code. Dmitry