emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 88d1e9b436c 2/2: Declare more functions as having important-retur


From: Mattias Engdegård
Subject: master 88d1e9b436c 2/2: Declare more functions as having important-return-value
Date: Sat, 20 May 2023 12:59:02 -0400 (EDT)

branch: master
commit 88d1e9b436c8778c90b7a57a152aee8071ac77b9
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Declare more functions as having important-return-value
    
    * lisp/subr.el (assoc-delete-all, assq-delete-all, rassq-delete-all)
    (alist-get): Declare as important-return-value.
    * lisp/emacs-lisp/bytecomp.el (important-return-value-fns):
    Add `assoc-string`.
---
 lisp/emacs-lisp/bytecomp.el | 2 +-
 lisp/subr.el                | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index deda4573229..b8d7b63a81a 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3561,7 +3561,7 @@ lambda-expression."
          ;; These functions are side-effect-free except for the
          ;; behaviour of functions passed as argument.
          mapcar mapcan mapconcat
-         assoc plist-get plist-member
+         assoc assoc-string plist-get plist-member
 
          ;; It's safe to ignore the value of `sort' and `nreverse'
          ;; when used on arrays, but most calls pass lists.
diff --git a/lisp/subr.el b/lisp/subr.el
index 8759c095f1a..f367095ad27 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -893,6 +893,7 @@ Non-strings in LIST are ignored."
 Compare keys with TEST.  Defaults to `equal'.
 Return the modified alist.
 Elements of ALIST that are not conses are ignored."
+  (declare (important-return-value t))
   (unless test (setq test #'equal))
   (while (and (consp (car alist))
              (funcall test (caar alist) key))
@@ -909,12 +910,14 @@ Elements of ALIST that are not conses are ignored."
   "Delete from ALIST all elements whose car is `eq' to KEY.
 Return the modified alist.
 Elements of ALIST that are not conses are ignored."
+  (declare (important-return-value t))
   (assoc-delete-all key alist #'eq))
 
 (defun rassq-delete-all (value alist)
   "Delete from ALIST all elements whose cdr is `eq' to VALUE.
 Return the modified alist.
 Elements of ALIST that are not conses are ignored."
+  (declare (important-return-value t))
   (while (and (consp (car alist))
              (eq (cdr (car alist)) value))
     (setq alist (cdr alist)))
@@ -957,6 +960,7 @@ Example:
   (setf (alist-get \\='b foo nil \\='remove) nil)
 
   foo => ((a . 1))"
+  (declare (important-return-value t))
   (ignore remove) ;;Silence byte-compiler.
   (let ((x (if (not testfn)
                (assq key alist)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]