diff options
author | Sam Steingold <sds@gnu.org> | 2022-07-28 12:35:21 -0400 |
---|---|---|
committer | Sam Steingold <sds@gnu.org> | 2022-07-28 12:36:21 -0400 |
commit | eeeb481750b5cec264af0f4ea5298cae011e5050 (patch) | |
tree | fa0a52ecceda4e14d10f714a3ec1a57982805a98 /lisp/subr.el | |
parent | 6023b95948e85f44d827e0066832de145737aea7 (diff) | |
download | emacs-eeeb481750b5cec264af0f4ea5298cae011e5050.tar.gz |
Cleanup `string-equal-ignore-case' declarations.
Also, a minor declaration cleanup for other `compare-strings' thin wrappers.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Remove
`string-equal-ignore-case', `string-prefix-p', `string-suffix-p'.
(side-effect-and-error-free-fns): Add `proper-list-p' (it already
was in `pure-fns').
(pure-fns): Remove `string-prefix-p', `string-suffix-p'
(`string-equal-ignore-case' was missing here).
* lisp/subr.el (proper-list-p): Remove partially duplicate `put's from here.
(string-equal-ignore-case, string-prefix-p, string-suffix-p): Add
`pure' and `side-effect-free' declarations.
(string-equal-ignore-case): Make inline.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index c82b33bba53..6b121a314a9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -733,11 +733,6 @@ If N is omitted or nil, remove the last element." (if (> n 0) (setcdr (nthcdr (- (1- m) n) list) nil)) list)))) -;; The function's definition was moved to fns.c, -;; but it's easier to set properties here. -(put 'proper-list-p 'pure t) -(put 'proper-list-p 'side-effect-free 'error-free) - (defun delete-dups (list) "Destructively remove `equal' duplicates from LIST. Store the result in LIST and return it. LIST must be a proper list. @@ -5302,16 +5297,18 @@ and replace a sub-expression, e.g. (setq matches (cons (substring string start l) matches)) ; leftover (apply #'concat (nreverse matches))))) -(defun string-equal-ignore-case (string1 string2) +(defsubst string-equal-ignore-case (string1 string2) "Like `string-equal', but case-insensitive. Upper-case and lower-case letters are treated as equal. Unibyte strings are converted to multibyte for comparison." + (declare (pure t) (side-effect-free t)) (eq t (compare-strings string1 0 nil string2 0 nil t))) (defun string-prefix-p (prefix string &optional ignore-case) "Return non-nil if PREFIX is a prefix of STRING. If IGNORE-CASE is non-nil, the comparison is done without paying attention to case differences." + (declare (pure t) (side-effect-free t)) (let ((prefix-length (length prefix))) (if (> prefix-length (length string)) nil (eq t (compare-strings prefix 0 prefix-length string @@ -5321,6 +5318,7 @@ to case differences." "Return non-nil if SUFFIX is a suffix of STRING. If IGNORE-CASE is non-nil, the comparison is done without paying attention to case differences." + (declare (pure t) (side-effect-free t)) (let ((start-pos (- (length string) (length suffix)))) (and (>= start-pos 0) (eq t (compare-strings suffix nil nil |