From 676ee88eea48ce76b2c8fc8eb24dcc9e948c3982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 29 Oct 2025 16:06:30 +0100 Subject: [PATCH] Faster constant pool string searching * lisp/emacs-lisp/bytecomp.el (byte-compile-get-constant): No reason not to use 'assoc' to search for strings as well. Previously we kept searching even after having found the string! --- lisp/emacs-lisp/bytecomp.el | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 3ba934b13ae..bf3d80f2d80 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3870,14 +3870,8 @@ assignment (i.e. `setq')." (byte-compile-dynamic-variable-op 'byte-varset var)))) (defmacro byte-compile-get-constant (const) - `(or (if (stringp ,const) - ;; In a string constant, treat properties as significant. - (let (result) - (dolist (elt byte-compile-constants) - (if (equal-including-properties (car elt) ,const) - (setq result elt))) - result) - (assoc ,const byte-compile-constants #'eql)) + `(or (assoc ,const byte-compile-constants + (if (stringp ,const) #'equal-including-properties #'eql)) (car (setq byte-compile-constants (cons (list ,const) byte-compile-constants)))))