]> git.eshelyaron.com Git - emacs.git/commitdiff
Reduce lread substitutions.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 27 Oct 2016 05:18:16 +0000 (01:18 -0400)
committerKen Raeburn <raeburn@raeburn.org>
Thu, 22 Jun 2017 02:34:32 +0000 (22:34 -0400)
* src/lread.c (read1): After reading an object using the "#n=" syntax,
if the read object is a cons cell, instead of recursively substituting
the placeholder with the new object, mutate the placeholder cons cell
itself to have the correct car and cdr values.

src/lread.c

index 263638651db8b27098533b0a22fbde6bbf4084ae..a6d04ec5af722a3683d712e63626fcb9e0ca4ad7 100644 (file)
@@ -2990,12 +2990,21 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
                      tem = read0 (readcharfun);
 
                      /* Now put it everywhere the placeholder was...  */
-                     Fsubstitute_object_in_subtree (tem, placeholder);
+                      if (CONSP (tem))
+                        {
+                          Fsetcar (placeholder, XCAR (tem));
+                          Fsetcdr (placeholder, XCDR (tem));
+                          return placeholder;
+                        }
+                      else
+                        {
+                         Fsubstitute_object_in_subtree (tem, placeholder);
 
-                     /* ...and #n# will use the real value from now on.  */
-                     Fsetcdr (cell, tem);
+                         /* ...and #n# will use the real value from now on.  */
+                         Fsetcdr (cell, tem);
 
-                     return tem;
+                         return tem;
+                        }
                    }
 
                  /* #n# returns a previously read object.  */