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]

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


Does it make any sense to change scm_makfromstr from:

SCM 
scm_makfromstr (const char *src, scm_sizet len, int slots)
{
  SCM s = scm_makstr (len, slots);
  char *dst = SCM_CHARS (s);

  while (len--)
    *dst++ = *src++;
  return s;
}

to something like:

SCM 
scm_makfromstr (const char *src, scm_sizet len, int slots)
{
  SCM s = scm_makstr (len, slots);

  memcpy (SCM_CHARS (s), src, len);
  return s;
}

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

-Dale
-- 
Dale P. Smith
Altus Technologies Corp.
dsmith@altustech.com
400-746-9000 x309

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