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 16:49:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Kang Niu <isgniuk@gmail.com> writes:

> Maybe the field functions are slow.
> I replaced the field functions with point-min and point-max
> (narrow-to-region (point-min) (point-max))
> and the overhead disappeared.

Reading the field functions, it seems like they don't check for the
common case -- that is, being called outside a field, and do a whole
lot of work that turns out to be pointless.

Does the following (untested) patch fix the performance problems? 

diff --git a/src/editfns.c b/src/editfns.c
index 5c9c34dc35..3e716a4544 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -437,6 +437,17 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
 
   after_field
     = get_char_property_and_overlay (pos, Qfield, Qnil, NULL);
+
+  /* We're not in a field, so just return `point-min'/`point-max'.  */
+  if (NILP (after_field))
+    {
+      if (beg)
+       *beg = BEGV;
+      if (end)
+       *end = ZV;
+      return;
+    }
+
   before_field
     = (XFIXNAT (pos) > BEGV
        ? get_char_property_and_overlay (make_fixnum (XFIXNUM (pos) - 1),


-- 
(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]