diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-02-26 16:56:24 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-02-27 14:34:22 +0100 |
commit | 1767d18c91a3c823d6ab6d69b2666fc5bc2f7d22 (patch) | |
tree | 93516d1da4a0caba4eee35232fbe792abca2ce42 /lisp/subr.el | |
parent | 443c249d85003639512d8d3b6ace184a9ff53bc2 (diff) | |
download | emacs-1767d18c91a3c823d6ab6d69b2666fc5bc2f7d22.tar.gz |
Adjust some `pure` and `side-effect-free` function declarations
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns):
Add `format-message` and `substring-no-properties`.
* lisp/subr.el (number-sequence, copy-tree, looking-at-p)
(string-match-p, string-trim-right, string-lines):
Declare side-effect-free.
(syntax-class, version-list-<, version-list-=, version-list-<=)
(version-list-not-zero): Declare pure and side-effect-free.
(ensure-list): Declare side-effect-free and error-free.
(string-equal-ignore-case): Remove `pure` declaration.
We may want it to be pure but right now it's not.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index ef2f63f7c37..2a8c51eb7c4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -806,6 +806,7 @@ TO as (+ FROM (* N INC)) or use a variable whose value was computed with this exact expression. Alternatively, you can, of course, also replace TO with a slightly larger value \(or a slightly more negative value if INC is negative)." + (declare (side-effect-free t)) (if (or (not to) (= from to)) (list from) (or inc (setq inc 1)) @@ -827,6 +828,7 @@ of course, also replace TO with a slightly larger value If TREE is a cons cell, this recursively copies both its car and its cdr. Contrast to `copy-sequence', which copies only along the cdrs. With second argument VECP, this copies vectors as well as conses." + (declare (side-effect-free t)) (if (consp tree) (let (result) (while (consp tree) @@ -5241,11 +5243,13 @@ wherever possible, since it is slow." (defsubst looking-at-p (regexp) "\ Same as `looking-at' except this function does not change the match data." + (declare (side-effect-free t)) (looking-at regexp t)) (defsubst string-match-p (regexp string &optional start) "\ Same as `string-match' except this function does not change the match data." + (declare (side-effect-free t)) (string-match regexp string start t)) (defun subregexp-context-p (regexp pos &optional start) @@ -5516,7 +5520,7 @@ Upper-case and lower-case letters are treated as equal. Unibyte strings are converted to multibyte for comparison. See also `string-equal'." - (declare (pure t) (side-effect-free t)) + (declare (side-effect-free t)) (eq t (compare-strings string1 0 nil string2 0 nil t))) (defun string-prefix-p (prefix string &optional ignore-case) @@ -5843,6 +5847,7 @@ integer that encodes the corresponding syntax class. See Info node `(elisp)Syntax Table Internals' for a list of codes. If SYNTAX is nil, return nil." + (declare (pure t) (side-effect-free t)) (and syntax (logand (car syntax) 65535))) ;; Utility motion commands @@ -6693,6 +6698,7 @@ Note that a version specified by the list (1) is equal to (1 0), \(1 0 0), (1 0 0 0), etc. That is, the trailing zeros are insignificant. Also, a version given by the list (1) is higher than (1 -1), which in turn is higher than (1 -2), which is higher than (1 -3)." + (declare (pure t) (side-effect-free t)) (while (and l1 l2 (= (car l1) (car l2))) (setq l1 (cdr l1) l2 (cdr l2))) @@ -6714,6 +6720,7 @@ Note that a version specified by the list (1) is equal to (1 0), \(1 0 0), (1 0 0 0), etc. That is, the trailing zeros are insignificant. Also, a version given by the list (1) is higher than (1 -1), which in turn is higher than (1 -2), which is higher than (1 -3)." + (declare (pure t) (side-effect-free t)) (while (and l1 l2 (= (car l1) (car l2))) (setq l1 (cdr l1) l2 (cdr l2))) @@ -6735,6 +6742,7 @@ Note that integer list (1) is equal to (1 0), (1 0 0), (1 0 0 0), etc. That is, the trailing zeroes are insignificant. Also, integer list (1) is greater than (1 -1) which is greater than (1 -2) which is greater than (1 -3)." + (declare (pure t) (side-effect-free t)) (while (and l1 l2 (= (car l1) (car l2))) (setq l1 (cdr l1) l2 (cdr l2))) @@ -6752,6 +6760,7 @@ which is greater than (1 -3)." "Return the first non-zero element of LST, which is a list of integers. If all LST elements are zeros or LST is nil, return zero." + (declare (pure t) (side-effect-free t)) (while (and lst (zerop (car lst))) (setq lst (cdr lst))) (if lst @@ -6918,6 +6927,7 @@ REGEXP defaults to \"[ \\t\\n\\r]+\"." "Trim STRING of trailing string matching REGEXP. REGEXP defaults to \"[ \\t\\n\\r]+\"." + (declare (side-effect-free t)) (let ((i (string-match-p (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") string))) (if i (substring string 0 i) string))) @@ -6989,6 +6999,7 @@ sentence (see Info node `(elisp) Documentation Tips')." "Return OBJECT as a list. If OBJECT is already a list, return OBJECT itself. If it's not a list, return a one-element list containing OBJECT." + (declare (side-effect-free error-free)) (if (listp object) object (list object))) @@ -7064,6 +7075,7 @@ is inserted before adjusting the number of empty lines." If OMIT-NULLS, empty lines will be removed from the results. If KEEP-NEWLINES, don't strip trailing newlines from the result lines." + (declare (side-effect-free t)) (if (equal string "") (if omit-nulls nil |