[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ea9831bb3cb 1/2: Better compilation of arguments to `ignore`
From: |
Mattias Engdegård |
Subject: |
master ea9831bb3cb 1/2: Better compilation of arguments to `ignore` |
Date: |
Wed, 12 Apr 2023 04:51:28 -0400 (EDT) |
branch: master
commit ea9831bb3cb4878273f6f848051c9b8c3c76d5f1
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Better compilation of arguments to `ignore`
* lisp/emacs-lisp/bytecomp.el (byte-compile-form)
(byte-compile-ignore):
Instead of compiling each `ignore` argument for value which is then
immediately discarded, compile it for effect but suppress
ignore-return-value warnings by passing the special value
`for-effect-no-warn` as for-effect parameter.
Proposed by Stefan Monnier.
---
lisp/emacs-lisp/bytecomp.el | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1b28fcd5093..c84c70971b3 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3563,6 +3563,8 @@ lambda-expression."
;;delq delete cl-delete
;;nconc plist-put
)))
+ ;; Don't warn for arguments to `ignore'.
+ (not (eq byte-compile--for-effect 'for-effect-no-warn))
(byte-compile-warning-enabled-p
'ignored-return-value (car form)))
(byte-compile-warn-x
@@ -4446,11 +4448,8 @@ This function is never called when `lexical-binding' is
nil."
(defun byte-compile-ignore (form)
(dolist (arg (cdr form))
- ;; Compile args for value (to avoid warnings about unused values),
- ;; emit a discard after each, and trust the LAP peephole optimiser
- ;; to annihilate useless ops.
- (byte-compile-form arg)
- (byte-compile-discard))
+ ;; Compile each argument for-effect but suppress unused-value warnings.
+ (byte-compile-form arg 'for-effect-no-warn))
(byte-compile-form nil))
;; Return the list of items in CONDITION-PARAM that match PRED-LIST.