emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 59f3c86 5/6: Create less garbage to collect while r


From: Ken Raeburn
Subject: [Emacs-diffs] master 59f3c86 5/6: Create less garbage to collect while reading symbols.
Date: Wed, 21 Jun 2017 22:57:31 -0400 (EDT)

branch: master
commit 59f3c86659c061e2673eb0da0bc78528d30f8f76
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 | 62 +++++++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/src/lread.c b/src/lread.c
index d6a7e55..3004e2b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3442,25 +3442,51 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
            if (! NILP (result))
              return unbind_to (count, result);
          }
+       {
+         Lisp_Object result;
+         ptrdiff_t nbytes = p - read_buffer;
+         ptrdiff_t nchars
+           = (multibyte
+              ? multibyte_chars_in_text ((unsigned char *) read_buffer,
+                                         nbytes)
+              : nbytes);
+
+         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.
 
-       ptrdiff_t nbytes = p - read_buffer;
-       ptrdiff_t nchars
-         = (multibyte
-            ? multibyte_chars_in_text ((unsigned char *) read_buffer,
-                                       nbytes)
-            : nbytes);
-       Lisp_Object name = ((uninterned_symbol && ! NILP (Vpurify_flag)
-                            ? make_pure_string : make_specified_string)
-                           (read_buffer, nchars, nbytes, multibyte));
-       Lisp_Object result = (uninterned_symbol ? Fmake_symbol (name)
-                             : Fintern (name, Qnil));
-
-       if (EQ (Vread_with_symbol_positions, Qt)
-           || EQ (Vread_with_symbol_positions, readcharfun))
-         Vread_symbol_positions_list
-           = Fcons (Fcons (result, make_number (start_position)),
-                    Vread_symbol_positions_list);
-       return unbind_to (count, result);
+                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))
+           Vread_symbol_positions_list
+             = Fcons (Fcons (result, make_number (start_position)),
+                      Vread_symbol_positions_list);
+         return unbind_to (count, result);
+       }
       }
     }
 }



reply via email to

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