This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Is there an equivalent to C's memcpy?

4 posts · 1345 views

Hey there!

What is the most efficient way to copy the content of s into d?
Is there an equivalent to C's memcpy?
(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?

Start with COPY-SEQUENCE; it is commonly optimized.

For reading files, try this.

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

replace is what I was looking for.

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

A word of warning: in my experience, replace can be slower than just concatenating new strings. Use your profiler.
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.