From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Performance of String Operations
Date: Sun, 11 Oct 2009 19:29:35 +0200 [thread overview]
Message-ID: <87ocodrg8w.fsf@galatea.local> (raw)
In-Reply-To: e6535800-cf57-4329-a392-4210959abab4@l13g2000yqb.googlegroups.com
Nordlöw <per.nordlow@gmail.com> writes:
> Does Emacs contain append/prepend/concat functions for strings that
> modify one of its (first) arguments (for side effects only)?
>
> If so, why not?
Because.
> Isn't such a function crucial to the performance of a
> language, regarding that strings is such a common object type?
No, mutation is not crucial to performance. On the contrary, it can
be detriemental. Functional programming languages are often faster
than programming languages having mutation.
> Or does the Emacs compiler optimize such things?
AFAIK, no.
> Can I somehow investigate how Emacs has optimized my lisp code?
Of course. You've got the sources.
Notice however that emacs provides a data structure for efficient
modification, notably for big strings. It is called a buffer.
For example:
(with-temp-buffer
(insert "hello world")
(delete-region 1 2)
(goto-char 1) (insert "H")
(delete-region 7 8)
(goto-char 7) (insert "W")
(end-of-line)
(insert "!")
(buffer-substring (point-min) (point-max)))
--> "Hello World!"
--
__Pascal Bourguignon__
next prev parent reply other threads:[~2009-10-11 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-11 6:41 Performance of String Operations Nordlöw
2009-10-11 10:05 ` Xah Lee
2009-10-11 14:40 ` Colin S. Miller
2009-10-11 15:38 ` Helmut Eller
2009-10-11 17:29 ` Pascal J. Bourguignon [this message]
2009-10-11 20:58 ` John A Pershing Jr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ocodrg8w.fsf@galatea.local \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).