all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Minor simplification in byte-opt.el
Date: Mon, 27 Jul 2020 11:38:55 +0200	[thread overview]
Message-ID: <ECDE2FF5-2FA7-4F2C-BCD6-4178FEFDBA8A@acm.org> (raw)
In-Reply-To: <jwvpn8ihv7b.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

26 juli 2020 kl. 22.41 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

> Could someone look over the patch below to confirm it's safe?

Thank you, looks decent to me. Good that you spotted the 1+/1-, I forgot about those.

> Also, as a result of this, there is only one call to
> `byte-optimize-form-code-walker` left, in `byte-optimize-form`, so maybe
> the two functions could be merged, tho it's probably not worth the trouble.

Maybe -- there seems to be little to gain from integrating them other than the elimination of the function call.

By the way, what about this little improvement?


[-- Attachment #2: 0001-Simplify-and-streamline-optimizer-clauses.patch --]
[-- Type: application/octet-stream, Size: 2507 bytes --]

From cc6cbb304193c62354d3cb6b0b76f8ce066b2189 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 27 Jul 2020 11:27:00 +0200
Subject: [PATCH] Simplify and streamline optimizer clauses

* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Remove clause for 'with-output-to-temp-buffer', since it is a
macro and will have been expanded before reaching this point.
Move clauses for 'lambda' and 'closure' to avoid splitting
a cond jump table.
---
 lisp/emacs-lisp/byte-opt.el | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 6f801be545..48efff911f 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -391,13 +391,6 @@ byte-optimize-form-code-walker
 	   (and (nth 1 form)
 		(not for-effect)
 		form))
-	  ((eq (car-safe fn) 'lambda)
-	   (let ((newform (byte-compile-unfold-lambda form)))
-	     (if (eq newform form)
-		 ;; Some error occurred, avoid infinite recursion
-		 form
-	       (byte-optimize-form-code-walker newform for-effect))))
-	  ((eq (car-safe fn) 'closure) form)
 	  ((memq fn '(let let*))
 	   ;; recursively enter the optimizer for the bindings and body
 	   ;; of a let or let*.  This for depth-firstness: forms that
@@ -444,13 +437,6 @@ byte-optimize-form-code-walker
 	   ;; will be optimized away in the lap-optimize pass.
 	   (cons fn (byte-optimize-body (cdr form) for-effect)))
 
-	  ((eq fn 'with-output-to-temp-buffer)
-	   ;; this is just like the above, except for the first argument.
-	   (cons fn
-	     (cons
-	      (byte-optimize-form (nth 1 form) nil)
-	      (byte-optimize-body (cdr (cdr form)) for-effect))))
-
 	  ((eq fn 'if)
 	   (when (< (length form) 3)
 	     (byte-compile-warn "too few arguments for `if'"))
@@ -530,6 +516,15 @@ byte-optimize-form-code-walker
           ;; Needed as long as we run byte-optimize-form after cconv.
           ((eq fn 'internal-make-closure) form)
 
+	  ((eq (car-safe fn) 'lambda)
+	   (let ((newform (byte-compile-unfold-lambda form)))
+	     (if (eq newform form)
+		 ;; Some error occurred, avoid infinite recursion
+		 form
+	       (byte-optimize-form-code-walker newform for-effect))))
+
+	  ((eq (car-safe fn) 'closure) form)
+
           ((byte-code-function-p fn)
            (cons fn (mapcar #'byte-optimize-form (cdr form))))
 
-- 
2.21.1 (Apple Git-122.3)


  reply	other threads:[~2020-07-27  9:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26 20:41 Minor simplification in byte-opt.el Stefan Monnier
2020-07-27  9:38 ` Mattias Engdegård [this message]
2020-07-27 14:24   ` Stefan Monnier
2020-07-28 14:43     ` Mattias Engdegård
2020-07-28 14:53       ` Stefan Monnier
2020-07-28 15:18         ` Mattias Engdegård
2020-07-28 16:08           ` Stefan Monnier

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ECDE2FF5-2FA7-4F2C-BCD6-4178FEFDBA8A@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.