From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: Optimising Elisp code Date: Fri, 05 Oct 2018 19:05:44 +0200 Message-ID: <87a7nsfhnb.fsf@telefonica.net> References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <86r2h44fqg.fsf@zoho.com> <86in2g4eq6.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538759062 1180 195.159.176.226 (5 Oct 2018 17:04:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 Oct 2018 17:04:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (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 19:04:18 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 1g8TWU-0000DS-6z for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2018 19:04:18 +0200 Original-Received: from localhost ([::1]:36202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8TYa-0004AW-MA for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Oct 2018 13:06:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8TY6-0004AC-6j for help-gnu-emacs@gnu.org; Fri, 05 Oct 2018 13:05:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8TY2-0003Q9-I4 for help-gnu-emacs@gnu.org; Fri, 05 Oct 2018 13:05:58 -0400 Original-Received: from [195.159.176.226] (port=54021 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8TY2-0003OD-Ad for help-gnu-emacs@gnu.org; Fri, 05 Oct 2018 13:05:54 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g8TVs-0007ww-3t for help-gnu-emacs@gnu.org; Fri, 05 Oct 2018 19:03:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Z8XKezIwJEbIhrJZt2grukMjHNA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 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:118128 Archived-At: Emanuel Berg writes: > 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. Just in case any bystander finds this post: don't rely on anything that is mentioned above, nor for C++ `inline' keyword nor for code inlining in general.