bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#52593: 28.0.90; (thing-at-point thing) has so much overhead since co


From: Lars Ingebrigtsen
Subject: bug#52593: 28.0.90; (thing-at-point thing) has so much overhead since commit 7db376e560448e61485ba054def8c82b21f33d6a
Date: Sun, 19 Dec 2021 15:44:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Kang Niu <isgniuk@gmail.com> writes:

> There are no fields in the buffer. (field-beginning) (field-end) return the 
> same value
> as (point-min) (point-max).

Odd.  Does the following fix the performance problem?  I'm wondering
whether it's the field functions that are slow or whether the
narrow-to-region is the thing that somehow triggers the slowness.

diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 2d1bf2013e..e746d94080 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -178,7 +178,11 @@ thing-at-point
 See the file `thingatpt.el' for documentation on how to define
 a symbol as a valid THING."
   (save-restriction
-    (narrow-to-region (field-beginning) (field-end))
+    (let ((beg (field-beginning))
+          (end (field-end)))
+      (when (or (not (= beg (point-min)))
+                (not (= end (point-max))))
+        (narrow-to-region (field-beginning) (field-end))))
     (let ((text
            (cond
             ((cl-loop for (pthing . function) in thing-at-point-provider-alist


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]