lkml.org 
[lkml]   [1998]   [Apr]   [24]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: faster strcpy()
DateFri, 24 Apr 1998 11:14:34 +0200
FromDavid Woodhouse <>
> > while(*a++=*b++); perhaps?
> 
> No, that's how it was before. This copies byte at time and is slow.
> memcpy is fast. If we could use the same technique as memcpy uses
> to copy strings and at the same time check the terminating 0...
> I don't see the answer myself, does anybody see?

I was just trying to remember it. The answer was written on a scrap of paper by
my Director of Studies, during a supervision near the end of last term, and I
_really_ ought to be able to remember it :)

It's something like subtracting 0x01010101 from the dword and oring with 
0x80808080 to detect the carry, but that's not quite it. Perhaps you do 
something like

 ((a - 0x01010101) xor a) & 0x808080

 but I thought it was simpler than that.




----                              ----                              ----
David Woodhouse, Robinson College, CB3 9AN, England.   (+44) 0976 658355
    Dave@imladris.demon.co.uk        http://www.imladris.demon.co.uk
	    finger pgp@dwmw2.robinson.cam.ac.uk for PGP key.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [from the cache]
©2003-2008