]> git.eshelyaron.com Git - emacs.git/commitdiff
Make object-intervals linear instead of quadratic
authorMattias Engdegård <mattiase@acm.org>
Sun, 14 Jan 2024 11:50:36 +0000 (12:50 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sun, 14 Jan 2024 13:17:41 +0000 (14:17 +0100)
* src/fns.c (collect_interval, Fobject_intervals):
Build the returned list in reverse instead of appending single
elements.

src/fns.c

index 07bb5115b6cfc8a1fa0feaa88ee77d2c6853cef9..acfedbfa922332e44d07054b133850eea37a69ca 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -5255,11 +5255,11 @@ static void
 collect_interval (INTERVAL interval, void *arg)
 {
   Lisp_Object *collector = arg;
-  *collector =
-    nconc2 (*collector,
-           list1(list3 (make_fixnum (interval->position),
-                        make_fixnum (interval->position + LENGTH (interval)),
-                        interval->plist)));
+  *collector = Fcons (list3 (make_fixnum (interval->position),
+                            make_fixnum (interval->position
+                                         + LENGTH (interval)),
+                            interval->plist),
+                     *collector);
 }
 
 
@@ -6312,7 +6312,6 @@ Altering this copy does not change the layout of the text properties
 in OBJECT.  */)
   (register Lisp_Object object)
 {
-  Lisp_Object collector = Qnil;
   INTERVAL intervals;
 
   if (STRINGP (object))
@@ -6325,8 +6324,9 @@ in OBJECT.  */)
   if (! intervals)
     return Qnil;
 
+  Lisp_Object collector = Qnil;
   traverse_intervals (intervals, 0, collect_interval, &collector);
-  return collector;
+  return Fnreverse (collector);
 }
 
 DEFUN ("line-number-at-pos", Fline_number_at_pos,