diff options
| author | Mattias EngdegÄrd | 2026-02-28 18:48:27 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2026-03-02 21:36:26 +0100 |
| commit | 423a8b7fd8b8fcfe894093b85ffc933ae1bd0fac (patch) | |
| tree | 89474a2559e1f8068fbd4d49564b2ffecece1241 | |
| parent | e96bb822e3b47552d8ebf369af6255f5f21ca780 (diff) | |
| download | emacs-423a8b7fd8b8fcfe894093b85ffc933ae1bd0fac.tar.gz emacs-423a8b7fd8b8fcfe894093b85ffc933ae1bd0fac.zip | |
Simplify some overly defensive compiler macros
* lisp/emacs-lisp/bytecomp.el (bytecomp--check-eq-args)
(bytecomp--check-memq-args, bytecomp--char-before)
(bytecomp--backward-char, bytecomp--backward-word):
Don't bother with malformed calls; macroexp--compiler-macro won't call
the handler unless the arity matches.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 8e65fafe36d..35594bb4dab 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -5912,7 +5912,7 @@ and corresponding effects." | |||
| 5912 | (car form) type parenthesis) | 5912 | (car form) type parenthesis) |
| 5913 | form (list 'suspicious (car form)) t)) | 5913 | form (list 'suspicious (car form)) t)) |
| 5914 | 5914 | ||
| 5915 | (defun bytecomp--check-eq-args (form &optional a b &rest _ignore) | 5915 | (defun bytecomp--check-eq-args (form a b) |
| 5916 | (let* ((number-ok (eq (car form) 'eql)) | 5916 | (let* ((number-ok (eq (car form) 'eql)) |
| 5917 | (bad-arg (cond ((bytecomp--dodgy-eq-arg-p a number-ok) 1) | 5917 | (bad-arg (cond ((bytecomp--dodgy-eq-arg-p a number-ok) 1) |
| 5918 | ((bytecomp--dodgy-eq-arg-p b number-ok) 2)))) | 5918 | ((bytecomp--dodgy-eq-arg-p b number-ok) 2)))) |
| @@ -5926,7 +5926,7 @@ and corresponding effects." | |||
| 5926 | (put 'eq 'compiler-macro #'bytecomp--check-eq-args) | 5926 | (put 'eq 'compiler-macro #'bytecomp--check-eq-args) |
| 5927 | (put 'eql 'compiler-macro #'bytecomp--check-eq-args) | 5927 | (put 'eql 'compiler-macro #'bytecomp--check-eq-args) |
| 5928 | 5928 | ||
| 5929 | (defun bytecomp--check-memq-args (form &optional elem list &rest _ignore) | 5929 | (defun bytecomp--check-memq-args (form elem list) |
| 5930 | (let* ((fn (car form)) | 5930 | (let* ((fn (car form)) |
| 5931 | (number-ok (eq fn 'memql))) | 5931 | (number-ok (eq fn 'memql))) |
| 5932 | (cond | 5932 | (cond |
| @@ -5964,22 +5964,16 @@ and corresponding effects." | |||
| 5964 | ;; their own byte-ops. | 5964 | ;; their own byte-ops. |
| 5965 | 5965 | ||
| 5966 | (put 'char-before 'compiler-macro #'bytecomp--char-before) | 5966 | (put 'char-before 'compiler-macro #'bytecomp--char-before) |
| 5967 | (defun bytecomp--char-before (form &optional arg &rest junk-args) | 5967 | (defun bytecomp--char-before (_form &optional arg) |
| 5968 | (if junk-args | 5968 | `(char-after (1- (or ,arg (point))))) |
| 5969 | form ; arity error | ||
| 5970 | `(char-after (1- (or ,arg (point)))))) | ||
| 5971 | 5969 | ||
| 5972 | (put 'backward-char 'compiler-macro #'bytecomp--backward-char) | 5970 | (put 'backward-char 'compiler-macro #'bytecomp--backward-char) |
| 5973 | (defun bytecomp--backward-char (form &optional arg &rest junk-args) | 5971 | (defun bytecomp--backward-char (_form &optional arg) |
| 5974 | (if junk-args | 5972 | `(forward-char (- (or ,arg 1)))) |
| 5975 | form ; arity error | ||
| 5976 | `(forward-char (- (or ,arg 1))))) | ||
| 5977 | 5973 | ||
| 5978 | (put 'backward-word 'compiler-macro #'bytecomp--backward-word) | 5974 | (put 'backward-word 'compiler-macro #'bytecomp--backward-word) |
| 5979 | (defun bytecomp--backward-word (form &optional arg &rest junk-args) | 5975 | (defun bytecomp--backward-word (_form &optional arg) |
| 5980 | (if junk-args | 5976 | `(forward-word (- (or ,arg 1)))) |
| 5981 | form ; arity error | ||
| 5982 | `(forward-word (- (or ,arg 1))))) | ||
| 5983 | 5977 | ||
| 5984 | (defun bytecomp--check-keyword-args (form arglist allowed-keys required-keys) | 5978 | (defun bytecomp--check-keyword-args (form arglist allowed-keys required-keys) |
| 5985 | (let ((fun (car form))) | 5979 | (let ((fun (car form))) |