From: David Ponce Date: Sun, 2 Mar 2025 01:41:24 +0000 (+0100) Subject: Simplify and speed up widget-get implementation X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=56890c51e11ba2e1cf77a65749c6d9efa9914a42;p=emacs.git Simplify and speed up widget-get implementation * 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) --- diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 558769834df..9300c5018fb 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -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.