From: Stefan Monnier Date: Mon, 12 May 2025 21:20:12 +0000 (-0400) Subject: (hash-table-contains-p): Don't allocate memory (bug#78162) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=72298c955f2763de0015aa008d973afa2000c2c8;p=emacs.git (hash-table-contains-p): Don't allocate memory (bug#78162) * lisp/subr.el (static-when): Remove spurious extra `progn` and improve warning message's location info. (hash-table-contains-p): Don't allocate memory (bug#78162). Suggested by Daniel Mendler . (cherry picked from commit 872658764823bb805796002c46c0e6e4456e65b7) --- diff --git a/lisp/subr.el b/lisp/subr.el index 62f395fc27d..bbd0b32a31c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -6893,11 +6893,11 @@ TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"." (declare (important-return-value t)) (string-trim-left (string-trim-right string trim-right) trim-left)) -(defsubst hash-table-contains-p (key table) - "Return non-nil if TABLE has an element with KEY." - (declare (side-effect-free t) - (important-return-value t)) - (let ((missing (make-symbol "missing"))) +(let ((missing (make-symbol "missing"))) + (defsubst hash-table-contains-p (key table) + "Return non-nil if TABLE has an element with KEY." + (declare (side-effect-free t) + (important-return-value t)) (not (eq (gethash key table missing) missing)))) ;; The initial anchoring is for better performance in searching matches.