mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Inline side-effect-free declarations in cl-lib.el
* lisp/emacs-lisp/cl-macs.el: Move side-effect-free declarations from here... * lisp/emacs-lisp/cl-extra.el (cl-gcd, cl-lcm, cl-isqrt, cl-floor) (cl-ceiling, cl-truncate, cl-round, cl-mod, cl-rem, cl-signum) (cl-subseq, cl-list-length, cl-get, cl-getf): * lisp/emacs-lisp/cl-lib.el (cl-plusp, cl-minusp, cl-oddp, cl-evenp) (cl-fifth, cl-sixth, cl-seventh, cl-eighth, cl-ninth, cl-tenth) (cl-ldiff, cl-pairlis): * lisp/emacs-lisp/cl-seq.el (cl-endp): ...to have them inline here. * lisp/emacs-lisp/cl-macs.el: Move side-effect-and-error-free declarations from here... * lisp/emacs-lisp/cl-extra.el (cl-equalp, cl-random-state-p): * lisp/emacs-lisp/cl-lib.el (cl-list*, cl-acons): ...to have them inline here. (Bug#76247)
This commit is contained in:
parent
745847ba8e
commit
7d9e67be13
4 changed files with 44 additions and 27 deletions
|
|
@ -272,20 +272,24 @@ so that they are registered at compile-time as well as run-time."
|
|||
|
||||
(defsubst cl-plusp (number)
|
||||
"Return t if NUMBER is positive."
|
||||
(declare (side-effect-free t))
|
||||
(> number 0))
|
||||
|
||||
(defsubst cl-minusp (number)
|
||||
"Return t if NUMBER is negative."
|
||||
(declare (side-effect-free t))
|
||||
(< number 0))
|
||||
|
||||
(defun cl-oddp (integer)
|
||||
"Return t if INTEGER is odd."
|
||||
(declare (compiler-macro (lambda (_) `(eq (logand ,integer 1) 1))))
|
||||
(declare (side-effect-free t)
|
||||
(compiler-macro (lambda (_) `(eq (logand ,integer 1) 1))))
|
||||
(eq (logand integer 1) 1))
|
||||
|
||||
(defun cl-evenp (integer)
|
||||
"Return t if INTEGER is even."
|
||||
(declare (compiler-macro (lambda (_) `(eq (logand ,integer 1) 0))))
|
||||
(declare (side-effect-free t)
|
||||
(compiler-macro (lambda (_) `(eq (logand ,integer 1) 0))))
|
||||
(eq (logand integer 1) 0))
|
||||
|
||||
(defconst cl-digit-char-table
|
||||
|
|
@ -387,32 +391,38 @@ SEQ, this is like `mapcar'. With several, it is like the Common Lisp
|
|||
|
||||
(defsubst cl-fifth (x)
|
||||
"Return the fifth element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 4 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 4 ,x) ,store))))
|
||||
(nth 4 x))
|
||||
|
||||
(defsubst cl-sixth (x)
|
||||
"Return the sixth element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 5 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 5 ,x) ,store))))
|
||||
(nth 5 x))
|
||||
|
||||
(defsubst cl-seventh (x)
|
||||
"Return the seventh element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 6 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 6 ,x) ,store))))
|
||||
(nth 6 x))
|
||||
|
||||
(defsubst cl-eighth (x)
|
||||
"Return the eighth element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 7 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 7 ,x) ,store))))
|
||||
(nth 7 x))
|
||||
|
||||
(defsubst cl-ninth (x)
|
||||
"Return the ninth element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 8 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 8 ,x) ,store))))
|
||||
(nth 8 x))
|
||||
|
||||
(defsubst cl-tenth (x)
|
||||
"Return the tenth element of the list X."
|
||||
(declare (gv-setter (lambda (store) `(setcar (nthcdr 9 ,x) ,store))))
|
||||
(declare (side-effect-free t)
|
||||
(gv-setter (lambda (store) `(setcar (nthcdr 9 ,x) ,store))))
|
||||
(nth 9 x))
|
||||
|
||||
(defalias 'cl-caaar #'caaar)
|
||||
|
|
@ -456,7 +466,8 @@ SEQ, this is like `mapcar'. With several, it is like the Common Lisp
|
|||
Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
|
||||
`(cons A (cons B (cons C D)))'.
|
||||
\n(fn ARG...)"
|
||||
(declare (compiler-macro cl--compiler-macro-list*))
|
||||
(declare (side-effect-free error-free)
|
||||
(compiler-macro cl--compiler-macro-list*))
|
||||
(cond ((not rest) arg)
|
||||
((not (cdr rest)) (cons arg (car rest)))
|
||||
(t (let* ((n (length rest))
|
||||
|
|
@ -467,6 +478,7 @@ Thus, `(cl-list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
|
|||
|
||||
(defun cl-ldiff (list sublist)
|
||||
"Return a copy of LIST with the tail SUBLIST removed."
|
||||
(declare (side-effect-free t))
|
||||
(let ((res nil))
|
||||
(while (and (consp list) (not (eq list sublist)))
|
||||
(push (pop list) res))
|
||||
|
|
@ -523,6 +535,7 @@ Return a copy of TREE with all elements `eql' to OLD replaced by NEW.
|
|||
(defun cl-acons (key value alist)
|
||||
"Add KEY and VALUE to ALIST.
|
||||
Return a new list with (cons KEY VALUE) as car and ALIST as cdr."
|
||||
(declare (side-effect-free error-free))
|
||||
(cons (cons key value) alist))
|
||||
|
||||
(defun cl-pairlis (keys values &optional alist)
|
||||
|
|
@ -530,6 +543,7 @@ Return a new list with (cons KEY VALUE) as car and ALIST as cdr."
|
|||
Return a new alist composed by associating KEYS to corresponding VALUES;
|
||||
the process stops as soon as KEYS or VALUES run out.
|
||||
If ALIST is non-nil, the new pairs are prepended to it."
|
||||
(declare (side-effect-free t))
|
||||
(nconc (cl-mapcar 'cons keys values) alist))
|
||||
|
||||
;;; Miscellaneous.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue