summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@raeburn.org>2016-12-19 16:01:09 -0500
committerKen Raeburn <raeburn@raeburn.org>2017-06-21 22:34:33 -0400
commit59f3c86659c061e2673eb0da0bc78528d30f8f76 (patch)
tree0b2084ea3d637f4648e785bdb5f2b9140a86e228
parentb91455633b03add918af3eb166ac797fd6c95722 (diff)
downloademacs-59f3c86659c061e2673eb0da0bc78528d30f8f76.tar.gz
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.
-rw-r--r--src/lread.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/src/lread.c b/src/lread.c
index d6a7e55b98a..3004e2b1915 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);
+ }
}
}
}