Page 1 of 1

Is there an equivalent to C's memcpy?

Posted: Thu Mar 03, 2011 1:30 pm
by FAU
Hey there!

What is the most efficient way to copy the content of s into d?
Is there an equivalent to C's memcpy?

Code: Select all

(let ((s "hello world")
      (d (make-string 50)))
  ;; What is the most efficient way to copy the content of s into d?
  ;; Is there an equivalent to C's memcpy?
  )

Re: Is there an equivalent to C's memcpy?

Posted: Thu Mar 03, 2011 2:32 pm
by nuntius
Start with COPY-SEQUENCE; it is commonly optimized.

For reading files, try this.

Re: Is there an equivalent to C's memcpy?

Posted: Fri Mar 04, 2011 11:46 am
by FAU
replace is what I was looking for.

Re: Is there an equivalent to C's memcpy?

Posted: Fri Mar 04, 2011 1:33 pm
by Warren Wilkinson
A word of warning: in my experience, replace can be slower than just concatenating new strings. Use your profiler.