]> git.eshelyaron.com Git - emacs.git/commit
Lift widget functions from C to Lisp
authorStefan Kangas <stefankangas@gmail.com>
Fri, 28 Feb 2025 17:28:58 +0000 (18:28 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 20:52:00 +0000 (21:52 +0100)
commitaba1216900645932e08ab39accf7479ab623e625
tree1b45b8402710a5897db5b9a4b004e8022cd98822
parent6c5bf7ff034e468df769a617405d5ee2842b9c0b
Lift widget functions from C to Lisp

In the mid-1990s, these functions were moved from Lisp to C to
"improve performance".  However, Moore's Law, and perhaps other
improvements too, has made this rationale irrelevant.

On this machine, with --native-compilation=no, I observed only a
slight ~4% performance difference.  For example, displaying a buffer
full of widgets (e.g., 'M-x customize RET browse-url RET') takes 4ms
here, meaning the performance gap is under 0.1ms.  Even on less
powerful machines, this difference would remain imperceptible.  Given
this, let's lift these functions back to to Lisp, which offers the
usual benefits.

We already have solid test coverage, but let's add a more focused test
for 'widget-get' and 'widget-put' to be thorough.

* lisp/wid-edit.el (widget-put, widget-get, widget-apply): Move to
Lisp from...
* src/fns.c (Fwidget_put, Fwidget_get, Fwidget_apply): ...here.
(syms_of_fns): Remove defsubrs for the above functions.
* test/lisp/wid-edit-tests.el
(widget-test-editable-field-widget-get/put): New test.

(cherry picked from commit 8b659313b83c82cfe09af1638289fccdfc9af23d)
lisp/wid-edit.el
src/fns.c
test/lisp/wid-edit-tests.el