From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with define-inline. Date: Sat, 18 Nov 2017 09:53:44 -0500 Message-ID: References: <20171118134153.7341.67271@vcs0.savannah.gnu.org> <20171118134155.1BE4320416@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511016837 28801 195.159.176.226 (18 Nov 2017 14:53:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Nov 2017 14:53:57 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Vibhav Pant To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 18 15:53:53 2017 Return-path: Envelope-to: ged-emacs-devel@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 1eG4VC-000772-TI for ged-emacs-devel@m.gmane.org; Sat, 18 Nov 2017 15:53:51 +0100 Original-Received: from localhost ([::1]:50289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eG4VK-0002DF-CR for ged-emacs-devel@m.gmane.org; Sat, 18 Nov 2017 09:53:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eG4VE-0002D8-7c for emacs-devel@gnu.org; Sat, 18 Nov 2017 09:53:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eG4V9-0007ZI-Bg for emacs-devel@gnu.org; Sat, 18 Nov 2017 09:53:52 -0500 Original-Received: from pmta31.teksavvy.com ([76.10.157.38]:54780) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1eG4V9-0007Yi-4u for emacs-devel@gnu.org; Sat, 18 Nov 2017 09:53:47 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2EzHgDzRxBa/3HQSC1bHAEBAQQBAQoBA?= =?us-ascii?q?YM8gR81iTOEeY9CgX2Yc4VFAoRnQxQBAQEBAQEBAQEDaCiFIAEEAXkFCwsNJxI?= =?us-ascii?q?UGIphCKwYIQKKVgEBCAImgzSCB4M+gyuFBWKFLAWTCI82oH8ohzGXbDYjgXQ0I?= =?us-ascii?q?Qgygy6CWh0ZgWwji0kBAQE?= X-IPAS-Result: =?us-ascii?q?A2EzHgDzRxBa/3HQSC1bHAEBAQQBAQoBAYM8gR81iTOEeY9?= =?us-ascii?q?CgX2Yc4VFAoRnQxQBAQEBAQEBAQEDaCiFIAEEAXkFCwsNJxIUGIphCKwYIQKKV?= =?us-ascii?q?gEBCAImgzSCB4M+gyuFBWKFLAWTCI82oH8ohzGXbDYjgXQ0IQgygy6CWh0ZgWw?= =?us-ascii?q?ji0kBAQE?= X-IronPort-AV: E=Sophos;i="5.44,415,1505793600"; d="scan'208";a="9292251" Original-Received: from unknown (HELO pastel.home) ([45.72.208.113]) by smtp.teksavvy.com with ESMTP; 18 Nov 2017 09:53:44 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 9CE5760770; Sat, 18 Nov 2017 09:53:44 -0500 (EST) In-Reply-To: <20171118134155.1BE4320416@vcs0.savannah.gnu.org> (Vibhav Pant's message of "Sat, 18 Nov 2017 08:41:54 -0500 (EST)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.10.157.38 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:220265 Archived-At: > Reimplement inline functions in ERC with define-inline. Yay, someone dared to use define-inline even though I haven't managed to document it yet! Thanks. > -(defsubst erc-dcc-unquote-filename (filename) > - (erc-replace-regexp-in-string "\\\\\\\\" "\\" > - (erc-replace-regexp-in-string "\\\\\"" "\"" filename t t) t t)) > +(define-inline erc-dcc-unquote-filename (filename) > + (inline-quote > + (erc-replace-regexp-in-string "\\\\\\\\" "\\" > + (erc-replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t))) Is it worth the trouble to inline this function at all? I find it hard to believe that the extra function call overhead would ever be noticeable compared to the time to do the two regexp replacements. > -(defsubst erc-nickserv-alist-sender (network &optional entry) > - (nth 1 (or entry (assoc network erc-nickserv-alist)))) > +(define-inline erc-nickserv-alist-sender (network &optional entry) > + (inline-quote (nth 1 (or ,entry (assoc ,network erc-nickserv-alist))))) When inlined, `entry` will be evaluated before `network`. Worse yet: `network` won't be evaluated at all if `entry` is non-nil. So it won't behave the same when inlined than when non-inlined, which I'd consider as a bug. AFAICT, `entry` is never passed anyway, so you could just remove it. > -(defsubst erc-get-server-user (nick) > +(define-inline erc-get-server-user (nick) > "Find the USER corresponding to NICK in the current server's > `erc-server-users' hash table." > - (erc-with-server-buffer > - (gethash (erc-downcase nick) erc-server-users))) > + (inline-quote (erc-with-server-buffer > + (gethash (erc-downcase ,nick) erc-server-users)))) This will evaluate `nick` in another buffer than the caller's current-buffer, so if the argument refers to buffer-local variables the result may be different when inlined than it would be when not inlined. Stefan