From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Performance of String Operations Date: Sun, 11 Oct 2009 19:29:35 +0200 Organization: Informatimago Message-ID: <87ocodrg8w.fsf@galatea.local> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1255282933 30123 80.91.229.12 (11 Oct 2009 17:42:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 11 Oct 2009 17:42:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 11 19:41:46 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mx2QQ-00054C-Pi for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Oct 2009 19:41:43 +0200 Original-Received: from localhost ([127.0.0.1]:57914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mx2QQ-0004Vk-B5 for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Oct 2009 13:41:42 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 50 Original-X-Trace: individual.net pdaPX2lLXUSnDOBPqRH6hgLne4U5SwB5j7Qh8oi/36m80v4b8m Cancel-Lock: sha1:YWYyNjZlZjk4MmQ2ZGM3MjIyZDQ3M2RhY2EwZWY0MmEyYTlhYjYxMw== sha1:xU0o6LMT6CmuRpU4ekL3zHWu39Y= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:173761 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68845 Archived-At: Nordlöw 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__