lkml.org 
[lkml]   [1998]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: faster strcpy()
Date
In article <linux.kernel.19980424215534.B1674@caffeine.ix.net.nz>,
Chris Wedgwood <chris@cybernet.co.nz> wrote:
>On Fri, Apr 24, 1998 at 02:20:13AM -0500, umforema@cc.UManitoba.CA wrote:
>> I'm not sure if this is a libc thing or a kernel thing, but I noticed
>> that strcpy is in the kernel include files, so here goes...
>> I changed the definition of strcpy in /usr/include/string.h to
>>
>> #define strcpy(a,b) (char *)memcpy(a,b,strlen(b))
>>
>> It slightly more than doubles the speed of strcpy on my pentium machine.
>
>Its a userland thing. The kernel has its own string functions.
>
>
>As to why the above is faster in userland, that seems really odd.

I'd guess that the strlen() preloads the source string into
cache, so memcpy() doesn't need to hit core for anything other
than writing the data out, and thus you avoid those icky
read cycles.


____
david parsons \bi/ I am not an electrical engineer.
\/

-
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    [W:1.005 / U:0.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site