This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Using memcpy instead of `*dst++ = *src++'


On Mon, Jun 05, 2000 at 08:51:21AM -0400, Dale P. Smith wrote:
> Does it make any sense to change scm_makfromstr from:
> 
>   while (len--)
>     *dst++ = *src++;
>
> to something like:
> 
>   memcpy (SCM_CHARS (s), src, len);
> 
> ???  I would guess that for small strings the overhead of a function call might slow things down.  But memcpy is supposedly tuned for better performance that a simple char by char copy.  I got a
> slight improvement, but it was in the system, not user timings. ???  It's probably very architecture and C library dependent.

Pros:
memcpy is slightly clearer
memcpy is likely to be optimized

Cons:
ideally the compiler could recognize the loop as equivilent to memcpy anyways
function call overhead

I would go for memcpy. That's what it's there for.

-- 
C. Ray C. aka Christopher Cramer
crayc@pyro.net
http://www.pyro.net/~crayc/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]