emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/raeburn-startup 3b47eb4 02/17: Reduce lread substi


From: Ken Raeburn
Subject: [Emacs-diffs] scratch/raeburn-startup 3b47eb4 02/17: Reduce lread substitutions.
Date: Thu, 15 Dec 2016 11:33:17 +0000 (UTC)

branch: scratch/raeburn-startup
commit 3b47eb4dba691e3b98c8af348682472b85d6c62d
Author: Stefan Monnier <address@hidden>
Commit: Ken Raeburn <address@hidden>

    Reduce lread substitutions.
    
    * 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 |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index ada5cbf..2d87c4c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2940,12 +2940,21 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
                      tem = read0 (readcharfun);
 
                      /* Now put it everywhere the placeholder was...  */
-                     substitute_object_in_subtree (tem, placeholder);
+                      if (CONSP (tem))
+                        {
+                          Fsetcar (placeholder, XCAR (tem));
+                          Fsetcdr (placeholder, XCDR (tem));
+                          return placeholder;
+                        }
+                      else
+                        {
+                         substitute_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.  */



reply via email to

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