This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Using memcpy instead of `*dst++ = *src++'
- To: "guile at sourceware dot cygnus dot com" <guile at sourceware dot cygnus dot com>
- Subject: Re: Using memcpy instead of `*dst++ = *src++'
- From: Chris Cramer <crayc at kiwi dot pyro dot net>
- Date: Tue, 6 Jun 2000 05:17:24 -0500
- References: <393BA182.90F39A35@en.com>
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/