Re: faster strcpy()

Anthony Barbachan (barbacha@trill.cis.fordham.edu)
Sat, 25 Apr 1998 21:27:00 -0400


-----Original Message-----
From: David Woodhouse <Dave@imladris.demon.co.uk>
To: Meelis Roos <mroos@tartu.cyber.ee>
Cc: linux-kernel@vger.rutgers.edu <linux-kernel@vger.rutgers.edu>
Date: Friday, April 24, 1998 5:44 AM
Subject: Re: faster strcpy()

>> > 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
>

This plus the rest of the associated checking code would probably take
longer than the original method

> 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
>

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