emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/raeburn-startup 8351395: Create less garbage to co


From: Ken Raeburn
Subject: [Emacs-diffs] scratch/raeburn-startup 8351395: Create less garbage to collect while reading symbols.
Date: Tue, 20 Dec 2016 14:43:33 +0000 (UTC)

branch: scratch/raeburn-startup
commit 83513956ce9544a71e3edabe14bf9cbcedecce12
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>

    Create less garbage to collect while reading symbols.
    
    * src/lread.c (read1): When interning a symbol, only create a new
    string object for the name if we're going to use it for a new symbol
    object.
---
 src/lread.c |   35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index 62a55e7..e9abe77 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3495,7 +3495,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
              return result;
          }
        {
-         Lisp_Object name, result;
+         Lisp_Object result;
          ptrdiff_t nbytes = p - read_buffer;
          ptrdiff_t nchars
            = (multibyte
@@ -3503,11 +3503,34 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
                                          nbytes)
               : nbytes);
 
-         name = ((uninterned_symbol && ! NILP (Vpurify_flag)
-                  ? make_pure_string : make_specified_string)
-                 (read_buffer, nchars, nbytes, multibyte));
-         result = (uninterned_symbol ? Fmake_symbol (name)
-                   : Fintern (name, Qnil));
+         if (uninterned_symbol)
+           {
+             Lisp_Object name
+               = ((! NILP (Vpurify_flag)
+                   ? make_pure_string : make_specified_string)
+                  (read_buffer, nchars, nbytes, multibyte));
+             result = Fmake_symbol (name);
+           }
+         else
+           {
+             /* Don't create the string object for the name unless
+                we're going to retain it in a new symbol.
+
+                Like intern_1 but supports multibyte names.  */
+             Lisp_Object obarray = check_obarray (Vobarray);
+             Lisp_Object tem = oblookup (obarray, read_buffer,
+                                         nchars, nbytes);
+
+             if (SYMBOLP (tem))
+               result = tem;
+             else
+               {
+                 Lisp_Object name
+                   = make_specified_string (read_buffer, nchars, nbytes,
+                                            multibyte);
+                 result = intern_driver (name, obarray, tem);
+               }
+           }
 
          if (EQ (Vread_with_symbol_positions, Qt)
              || EQ (Vread_with_symbol_positions, readcharfun))



reply via email to

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