Move side-effect-free and pure declarations to function definitions
Some Lisp functions still had their `side-effect-free` and `pure` properties declared in byte-opt.el; do it at their definition instead. The lists in byte-opt.el now only contain functions implemented in C and function aliases. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns) (side-effect-and-error-free-fns, pure-fns): Remove functions whose properties are now declared elsewhere and some obsolete entries. * lisp/custom.el (custom-variable-p): * lisp/emacs-lisp/lisp.el (buffer-end): * lisp/emacs-lisp/regexp-opt.el (regexp-opt): * lisp/env.el (getenv): * lisp/simple.el (count-lines, mark, string-empty-p, lax-plist-get): * lisp/subr.el (ignore, always, zerop, fixnump, bignump, lsh, last) (eventp, mouse-movement-p, log10, memory-limit, string-greaterp) (interactive-p): * lisp/window.el (get-lru-window, get-largest-window, (window-edges) (window-body-edges, window-pixel-edges, window-body-pixel-edges) (window-absolute-pixel-edges, window-absolute-body-pixel-edges) (one-window-p): Declare functions `side-effect-free` and/or `pure` as appropriate.
This commit is contained in:
parent
7ab6c6ac83
commit
d5bf26f488
8 changed files with 59 additions and 40 deletions
|
@ -665,6 +665,7 @@ If NOSET is non-nil, don't bother autoloading LOAD when setting the variable."
|
|||
A customizable variable is either (i) a variable whose property
|
||||
list contains a non-nil `standard-value' or `custom-autoload'
|
||||
property, or (ii) an alias for another customizable variable."
|
||||
(declare (side-effect-free t))
|
||||
(when (symbolp variable)
|
||||
(setq variable (indirect-variable variable))
|
||||
(or (get variable 'standard-value)
|
||||
|
|
|
@ -1647,7 +1647,7 @@ See Info node `(elisp) Integer Basics'."
|
|||
capitalize car-less-than-car car cdr ceiling char-after char-before
|
||||
char-equal char-to-string char-width compare-strings
|
||||
window-configuration-equal-p concat coordinates-in-window-p
|
||||
copy-alist copy-sequence copy-marker copysign cos count-lines
|
||||
copy-alist copy-sequence copy-marker copysign cos
|
||||
current-time-string current-time-zone
|
||||
decode-char
|
||||
decode-time default-boundp default-value documentation downcase
|
||||
|
@ -1659,26 +1659,24 @@ See Info node `(elisp) Integer Basics'."
|
|||
float float-time floor format format-time-string frame-first-window
|
||||
frame-root-window frame-selected-window
|
||||
frame-visible-p fround ftruncate
|
||||
get gethash get-buffer get-buffer-window getenv get-file-buffer
|
||||
get gethash get-buffer get-buffer-window get-file-buffer
|
||||
hash-table-count
|
||||
int-to-string intern-soft isnan
|
||||
keymap-parent
|
||||
lax-plist-get ldexp
|
||||
ldexp
|
||||
length length< length> length=
|
||||
line-beginning-position line-end-position pos-bol pos-eol
|
||||
local-variable-if-set-p local-variable-p locale-info
|
||||
log log10 logand logb logcount logior lognot logxor lsh
|
||||
make-byte-code make-list make-string make-symbol mark marker-buffer max
|
||||
log logand logb logcount logior lognot logxor
|
||||
make-byte-code make-list make-string make-symbol marker-buffer max
|
||||
match-beginning match-end
|
||||
member memq memql min minibuffer-selected-window minibuffer-window
|
||||
mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string
|
||||
parse-colon-path
|
||||
prefix-numeric-value previous-window prin1-to-string propertize
|
||||
degrees-to-radians
|
||||
radians-to-degrees rassq rassoc read-from-string regexp-opt
|
||||
rassq rassoc read-from-string
|
||||
regexp-quote region-beginning region-end reverse round
|
||||
sin sqrt string string< string= string-equal string-lessp
|
||||
string> string-greaterp string-empty-p string-blank-p
|
||||
string>
|
||||
string-search string-to-char
|
||||
string-to-number string-to-syntax substring
|
||||
sxhash sxhash-equal sxhash-eq sxhash-eql
|
||||
|
@ -1687,45 +1685,40 @@ See Info node `(elisp) Integer Basics'."
|
|||
string-to-multibyte
|
||||
take tan time-convert truncate
|
||||
unibyte-char-to-multibyte upcase user-full-name
|
||||
user-login-name user-original-login-name custom-variable-p
|
||||
user-login-name user-original-login-name
|
||||
vconcat
|
||||
window-absolute-pixel-edges window-at window-body-height
|
||||
window-at window-body-height
|
||||
window-body-width window-buffer window-dedicated-p window-display-table
|
||||
window-combination-limit window-edges window-frame window-fringes
|
||||
window-combination-limit window-frame window-fringes
|
||||
window-height window-hscroll window-inside-edges
|
||||
window-inside-absolute-pixel-edges window-inside-pixel-edges
|
||||
window-left-child window-left-column window-margins window-minibuffer-p
|
||||
window-next-buffers window-next-sibling window-new-normal
|
||||
window-new-total window-normal-size window-parameter window-parameters
|
||||
window-parent window-pixel-edges window-point window-prev-buffers
|
||||
window-parent window-point window-prev-buffers
|
||||
window-prev-sibling window-scroll-bars
|
||||
window-start window-text-height window-top-child window-top-line
|
||||
window-total-height window-total-width window-use-time window-vscroll
|
||||
window-width zerop))
|
||||
window-width))
|
||||
(side-effect-and-error-free-fns
|
||||
'(always arrayp atom
|
||||
bignump bobp bolp bool-vector-p
|
||||
buffer-end buffer-list buffer-size buffer-string bufferp
|
||||
'(arrayp atom
|
||||
bobp bolp bool-vector-p
|
||||
buffer-list buffer-size buffer-string bufferp
|
||||
car-safe case-table-p cdr-safe char-or-string-p characterp
|
||||
charsetp commandp cons consp
|
||||
current-buffer current-global-map current-indentation
|
||||
current-local-map current-minor-mode-maps current-time
|
||||
eobp eolp eq equal eventp
|
||||
fixnump floatp following-char framep
|
||||
get-largest-window get-lru-window
|
||||
eobp eolp eq equal
|
||||
floatp following-char framep
|
||||
hash-table-p
|
||||
;; `ignore' isn't here because we don't want calls to it elided;
|
||||
;; see `byte-compile-ignore'.
|
||||
identity integerp integer-or-marker-p interactive-p
|
||||
identity integerp integer-or-marker-p
|
||||
invocation-directory invocation-name
|
||||
keymapp keywordp
|
||||
list listp
|
||||
make-marker mark-marker markerp max-char
|
||||
memory-limit
|
||||
mouse-movement-p
|
||||
natnump nlistp not null number-or-marker-p numberp
|
||||
one-window-p overlayp
|
||||
point point-marker point-min point-max preceding-char primary-charset
|
||||
overlayp
|
||||
point point-marker point-min point-max preceding-char
|
||||
processp proper-list-p
|
||||
recent-keys recursion-depth
|
||||
safe-length selected-frame selected-window sequencep
|
||||
|
@ -1761,7 +1754,7 @@ See Info node `(elisp) Integer Basics'."
|
|||
;; values if a marker is moved.
|
||||
|
||||
(let ((pure-fns
|
||||
'(concat regexp-opt regexp-quote
|
||||
'(concat regexp-quote
|
||||
string-to-char string-to-syntax symbol-name
|
||||
eq eql
|
||||
= /= < <= >= > min max
|
||||
|
@ -1770,8 +1763,7 @@ See Info node `(elisp) Integer Basics'."
|
|||
copysign isnan ldexp float logb
|
||||
floor ceiling round truncate
|
||||
ffloor fceiling fround ftruncate
|
||||
string= string-equal string< string-lessp string> string-greaterp
|
||||
string-empty-p string-blank-p
|
||||
string= string-equal string< string-lessp string>
|
||||
string-search
|
||||
consp atom listp nlistp proper-list-p
|
||||
sequencep arrayp vectorp stringp bool-vector-p hash-table-p
|
||||
|
@ -1780,20 +1772,19 @@ See Info node `(elisp) Integer Basics'."
|
|||
integer-or-marker-p number-or-marker-p char-or-string-p
|
||||
symbolp keywordp
|
||||
type-of
|
||||
identity ignore
|
||||
identity
|
||||
|
||||
;; The following functions are pure up to mutation of their
|
||||
;; arguments. This is pure enough for the purposes of
|
||||
;; constant folding, but not necessarily for all kinds of
|
||||
;; code motion.
|
||||
car cdr car-safe cdr-safe nth nthcdr last take
|
||||
car cdr car-safe cdr-safe nth nthcdr take
|
||||
equal
|
||||
length safe-length
|
||||
memq memql member
|
||||
;; `assoc' and `assoc-default' are excluded since they are
|
||||
;; impure if the test function is (consider `string-match').
|
||||
assq rassq rassoc
|
||||
lax-plist-get
|
||||
aref elt
|
||||
base64-decode-string base64-encode-string base64url-encode-string
|
||||
bool-vector-subsetp
|
||||
|
|
|
@ -519,6 +519,7 @@ major mode's decisions about context.")
|
|||
"Return the \"far end\" position of the buffer, in direction ARG.
|
||||
If ARG is positive, that's the end of the buffer.
|
||||
Otherwise, that's the beginning of the buffer."
|
||||
(declare (side-effect-free error-free))
|
||||
(if (> arg 0) (point-max) (point-min)))
|
||||
|
||||
(defun end-of-defun (&optional arg interactive)
|
||||
|
|
|
@ -130,6 +130,7 @@ usually more efficient than that of a simplified version:
|
|||
(concat (car parens)
|
||||
(mapconcat \\='regexp-quote strings \"\\\\|\")
|
||||
(cdr parens))))"
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(save-match-data
|
||||
;; Recurse on the sorted list.
|
||||
(let* ((max-lisp-eval-depth 10000)
|
||||
|
|
|
@ -205,6 +205,7 @@ Otherwise, this function searches `process-environment' for
|
|||
VARIABLE. If it is not found there, then it continues the search
|
||||
in the environment list of the selected frame."
|
||||
(interactive (list (read-envvar-name "Get environment variable: " t)))
|
||||
(declare (side-effect-free t))
|
||||
(let ((value (getenv-internal (if (multibyte-string-p variable)
|
||||
(encode-coding-string
|
||||
variable locale-coding-system)
|
||||
|
|
|
@ -1755,6 +1755,7 @@ not at the start of a line.
|
|||
|
||||
When IGNORE-INVISIBLE-LINES is non-nil, invisible lines are not
|
||||
included in the count."
|
||||
(declare (side-effect-free t))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region start end)
|
||||
|
@ -6830,6 +6831,7 @@ is active, and returns an integer or nil in the usual way.
|
|||
|
||||
If you are using this in an editing command, you are most likely making
|
||||
a mistake; see the documentation of `set-mark'."
|
||||
(declare (side-effect-free t))
|
||||
(if (or force (not transient-mark-mode) mark-active mark-even-if-inactive)
|
||||
(marker-position (mark-marker))
|
||||
(signal 'mark-inactive nil)))
|
||||
|
@ -10840,6 +10842,7 @@ If the buffer doesn't exist, create it first."
|
|||
|
||||
(defsubst string-empty-p (string)
|
||||
"Check whether STRING is empty."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(string= string ""))
|
||||
|
||||
(defun read-signal-name ()
|
||||
|
@ -10857,7 +10860,7 @@ If the buffer doesn't exist, create it first."
|
|||
|
||||
(defun lax-plist-get (plist prop)
|
||||
"Extract a value from a property list, comparing with `equal'."
|
||||
(declare (obsolete plist-get "29.1"))
|
||||
(declare (pure t) (side-effect-free t) (obsolete plist-get "29.1"))
|
||||
(plist-get plist prop #'equal))
|
||||
|
||||
(defun lax-plist-put (plist prop val)
|
||||
|
|
24
lisp/subr.el
24
lisp/subr.el
|
@ -422,7 +422,9 @@ PREFIX is a string, and defaults to \"g\"."
|
|||
"Do nothing and return nil.
|
||||
This function accepts any number of ARGUMENTS, but ignores them.
|
||||
Also see `always'."
|
||||
(declare (completion ignore))
|
||||
;; Not declared `side-effect-free' because we don't want calls to it
|
||||
;; elided; see `byte-compile-ignore'.
|
||||
(declare (pure t) (completion ignore))
|
||||
(interactive)
|
||||
nil)
|
||||
|
||||
|
@ -430,6 +432,7 @@ Also see `always'."
|
|||
"Do nothing and return t.
|
||||
This function accepts any number of ARGUMENTS, but ignores them.
|
||||
Also see `ignore'."
|
||||
(declare (pure t) (side-effect-free error-free))
|
||||
t)
|
||||
|
||||
;; Signal a compile-error if the first arg is missing.
|
||||
|
@ -509,16 +512,19 @@ was called."
|
|||
"Return t if NUMBER is zero."
|
||||
;; Used to be in C, but it's pointless since (= 0 n) is faster anyway because
|
||||
;; = has a byte-code.
|
||||
(declare (compiler-macro (lambda (_) `(= 0 ,number))))
|
||||
(declare (pure t) (side-effect-free t)
|
||||
(compiler-macro (lambda (_) `(= 0 ,number))))
|
||||
(= 0 number))
|
||||
|
||||
(defun fixnump (object)
|
||||
"Return t if OBJECT is a fixnum."
|
||||
(declare (side-effect-free error-free))
|
||||
(and (integerp object)
|
||||
(<= most-negative-fixnum object most-positive-fixnum)))
|
||||
|
||||
(defun bignump (object)
|
||||
"Return t if OBJECT is a bignum."
|
||||
(declare (side-effect-free error-free))
|
||||
(and (integerp object) (not (fixnump object))))
|
||||
|
||||
(defun lsh (value count)
|
||||
|
@ -533,7 +539,8 @@ instead."
|
|||
(lambda (form)
|
||||
(macroexp-warn-and-return
|
||||
(format-message "avoid `lsh'; use `ash' instead")
|
||||
form '(suspicious lsh) t form))))
|
||||
form '(suspicious lsh) t form)))
|
||||
(side-effect-free t))
|
||||
(when (and (< value 0) (< count 0))
|
||||
(when (< value most-negative-fixnum)
|
||||
(signal 'args-out-of-range (list value count)))
|
||||
|
@ -706,7 +713,7 @@ instead."
|
|||
If LIST is nil, return nil.
|
||||
If N is non-nil, return the Nth-to-last link of LIST.
|
||||
If N is bigger than the length of LIST, return LIST."
|
||||
(declare (side-effect-free t))
|
||||
(declare (pure t) (side-effect-free t)) ; pure up to mutation
|
||||
(if n
|
||||
(and (>= n 0)
|
||||
(let ((m (safe-length list)))
|
||||
|
@ -1525,6 +1532,7 @@ See also `current-global-map'.")
|
|||
|
||||
(defun eventp (object)
|
||||
"Return non-nil if OBJECT is an input event or event object."
|
||||
(declare (pure t) (side-effect-free error-free))
|
||||
(or (integerp object)
|
||||
(and (if (consp object)
|
||||
(setq object (car object))
|
||||
|
@ -1587,6 +1595,7 @@ in the current Emacs session, then this function may return nil."
|
|||
|
||||
(defsubst mouse-movement-p (object)
|
||||
"Return non-nil if OBJECT is a mouse movement event."
|
||||
(declare (side-effect-free error-free))
|
||||
(eq (car-safe object) 'mouse-movement))
|
||||
|
||||
(defun mouse-event-p (object)
|
||||
|
@ -1859,7 +1868,7 @@ be a list of the form returned by `event-start' and `event-end'."
|
|||
|
||||
(defun log10 (x)
|
||||
"Return (log X 10), the log base 10 of X."
|
||||
(declare (obsolete log "24.4"))
|
||||
(declare (side-effect-free t) (obsolete log "24.4"))
|
||||
(log x 10))
|
||||
|
||||
(set-advertised-calling-convention
|
||||
|
@ -2983,6 +2992,7 @@ It can be retrieved with `(process-get PROCESS PROPNAME)'."
|
|||
|
||||
(defun memory-limit ()
|
||||
"Return an estimate of Emacs virtual memory usage, divided by 1024."
|
||||
(declare (side-effect-free error-free))
|
||||
(let ((default-directory temporary-file-directory))
|
||||
(or (cdr (assq 'vsize (process-attributes (emacs-pid)))) 0)))
|
||||
|
||||
|
@ -5544,6 +5554,7 @@ consisting of STR followed by an invisible left-to-right mark
|
|||
"Return non-nil if STRING1 is greater than STRING2 in lexicographic order.
|
||||
Case is significant.
|
||||
Symbols are also allowed; their print names are used instead."
|
||||
(declare (pure t) (side-effect-free t))
|
||||
(string-lessp string2 string1))
|
||||
|
||||
|
||||
|
@ -6187,7 +6198,8 @@ To test whether a function can be called interactively, use
|
|||
`commandp'."
|
||||
;; Kept around for now. See discussion at:
|
||||
;; https://lists.gnu.org/r/emacs-devel/2020-08/msg00564.html
|
||||
(declare (obsolete called-interactively-p "23.2"))
|
||||
(declare (obsolete called-interactively-p "23.2")
|
||||
(side-effect-free error-free))
|
||||
(called-interactively-p 'interactive))
|
||||
|
||||
(defun internal-push-keymap (keymap symbol)
|
||||
|
|
|
@ -2522,6 +2522,7 @@ selected frame and no others.
|
|||
`display-buffer-avoid-small-windows', if non-nil, is also taken into
|
||||
consideration. Windows whose height is smaller that the value of that
|
||||
variable will be avoided if larger windows are available."
|
||||
(declare (side-effect-free error-free))
|
||||
(let ((windows (window-list-1 nil 'nomini all-frames))
|
||||
best-window best-time second-best-window second-best-time time)
|
||||
(dolist (window windows)
|
||||
|
@ -2603,6 +2604,7 @@ have special meanings:
|
|||
|
||||
Any other value of ALL-FRAMES means consider all windows on the
|
||||
selected frame and no others."
|
||||
(declare (side-effect-free error-free))
|
||||
(let ((best-size 0)
|
||||
best-window size)
|
||||
(dolist (window (window-list-1 nil 'nomini all-frames))
|
||||
|
@ -3801,6 +3803,7 @@ frame, rounded if necessary. PIXELWISE non-nil means to return
|
|||
the coordinates in pixels where the values for RIGHT and BOTTOM
|
||||
are one more than the actual value of these edges. Note that if
|
||||
ABSOLUTE is non-nil, PIXELWISE is implicitly non-nil too."
|
||||
(declare (side-effect-free t))
|
||||
(let* ((window (window-normalize-window window body))
|
||||
(frame (window-frame window))
|
||||
(border-width (frame-internal-border-width frame))
|
||||
|
@ -3856,6 +3859,7 @@ ABSOLUTE is non-nil, PIXELWISE is implicitly non-nil too."
|
|||
"Return a list of the edge coordinates of WINDOW's body.
|
||||
The return value is that of `window-edges' called with argument
|
||||
BODY non-nil."
|
||||
(declare (side-effect-free t))
|
||||
(window-edges window t))
|
||||
(defalias 'window-inside-edges 'window-body-edges)
|
||||
|
||||
|
@ -3863,12 +3867,14 @@ BODY non-nil."
|
|||
"Return a list of the edge pixel coordinates of WINDOW.
|
||||
The return value is that of `window-edges' called with argument
|
||||
PIXELWISE non-nil."
|
||||
(declare (side-effect-free t))
|
||||
(window-edges window nil nil t))
|
||||
|
||||
(defun window-body-pixel-edges (&optional window)
|
||||
"Return a list of the edge pixel coordinates of WINDOW's body.
|
||||
The return value is that of `window-edges' called with arguments
|
||||
BODY and PIXELWISE non-nil."
|
||||
(declare (side-effect-free t))
|
||||
(window-edges window t nil t))
|
||||
(defalias 'window-inside-pixel-edges 'window-body-pixel-edges)
|
||||
|
||||
|
@ -3876,12 +3882,14 @@ BODY and PIXELWISE non-nil."
|
|||
"Return a list of the edge pixel coordinates of WINDOW.
|
||||
The return value is that of `window-edges' called with argument
|
||||
ABSOLUTE non-nil."
|
||||
(declare (side-effect-free t))
|
||||
(window-edges window nil t t))
|
||||
|
||||
(defun window-absolute-body-pixel-edges (&optional window)
|
||||
"Return a list of the edge pixel coordinates of WINDOW's text area.
|
||||
The return value is that of `window-edges' called with arguments
|
||||
BODY and ABSOLUTE non-nil."
|
||||
(declare (side-effect-free t))
|
||||
(window-edges window t t t))
|
||||
(defalias 'window-inside-absolute-pixel-edges 'window-absolute-body-pixel-edges)
|
||||
|
||||
|
@ -4091,6 +4099,7 @@ with a special meaning are:
|
|||
|
||||
Anything else means consider all windows on the selected frame
|
||||
and no others."
|
||||
(declare (side-effect-free error-free))
|
||||
(let ((base-window (selected-window)))
|
||||
(if (and nomini (eq base-window (minibuffer-window)))
|
||||
(setq base-window (next-window base-window)))
|
||||
|
|
Loading…
Add table
Reference in a new issue