]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify and speed up widget-get implementation
authorDavid Ponce <da_vid@orange.fr>
Sun, 2 Mar 2025 01:41:24 +0000 (02:41 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 20:58:08 +0000 (21:58 +0100)
* lisp/wid-edit.el (widget-get): Simplify and speed up.
Ref: https://lists.gnu.org/r/emacs-devel/2025-03/msg00010.html

(cherry picked from commit be8a7c9c882540dd7267f9046166cb680f10fd9d)

lisp/wid-edit.el

index 558769834df6097d9fd52ca6a5daebdbd71dea4d..9300c5018fb4454dcac73978424963ec9a1074b5 100644 (file)
@@ -633,16 +633,12 @@ The value can later be retrieved with `widget-get'."
   "In WIDGET, get the value of PROPERTY.
 The value could either be specified when the widget was created, or
 later with `widget-put'."
-  (let (tmp)
-    (catch 'found
-      (while widget
-        (cond ((and (setq tmp (plist-member (cdr widget) property))
-                    (consp tmp))
-               (throw 'found (cadr tmp)))
-              ((setq tmp (widget-type widget))
-               (setq widget (get tmp 'widget-type)))
-              (t
-               (throw 'found nil)))))))
+   (let (value found)
+     (while (and widget (not found))
+       (if (setq found (plist-member (cdr widget) property))
+           (setq value (cadr found))
+         (setq widget (get (widget-type widget) 'widget-type))))
+     value))
 
 (defun widget-get-indirect (widget property)
   "In WIDGET, get the value of PROPERTY.