From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Optimising Elisp code Date: Fri, 05 Oct 2018 17:04:17 +0200 Organization: Aioe.org NNTP Server Message-ID: <86in2g4eq6.fsf@zoho.com> References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <86r2h44fqg.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538751814 16393 195.159.176.226 (5 Oct 2018 15:03:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 Oct 2018 15:03:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 05 17:03:30 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g8RdZ-0004A5-Tw for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2018 17:03:30 +0200 Original-Received: from localhost ([::1]:35559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8Rfg-0001og-CY for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2018 11:05:40 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 50 Original-NNTP-Posting-Host: xQsFb8j6c/kdg9AvIrnVFA.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.3 Cancel-Lock: sha1:c0l7IKFTZnIdQ1dTgORDn4JwxlM= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:224000 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118126 Archived-At: > This rings a bell from the C++ days > when/where you could define a member function > as "inline". That's all I remember, but maybe > it was something similar to this? I think it > amounted to, instead of making a call, that > function was coded into the object itself, > and for this reason it was suited for really > short, simple functions. [...] > > If the caller is a function, does this mean > instead of calling the other function, the > other function's code is put into the first > function so there isn't a second call but > everything is executed in the first function? OK, in C++ it works like this: If a member function is defined within the class definition (not recommended), or if it is defined outside of it (recommended) with the word "inline" preceding the return type, then the function becomes an inline function. What this means is that when the code is compiled into machine code, instead of having one place for the function, and jumping back and forth every time that function is called, the machine code for the inline function is placed, duplicated wherever it is used. So you get longer machine code, but faster, since there is just constant execution for the inline functions, without jumping back and forth. When should it be used? If the function is very short, say 1-3 lines, the jumping back and forth requires more machine instructions than the function itself. Then the organizational gain of having it neatly at one place is diminished by the speed advantage of not having to jump back and forth to that place all the time. "Make the common case fast, and the complicated case work" -- M. Yoda -- underground experts united http://user.it.uu.se/~embe8573