diff options
| author | Ken Raeburn | 2016-12-19 16:01:09 -0500 |
|---|---|---|
| committer | Ken Raeburn | 2017-06-21 22:34:33 -0400 |
| commit | 59f3c86659c061e2673eb0da0bc78528d30f8f76 (patch) | |
| tree | 0b2084ea3d637f4648e785bdb5f2b9140a86e228 /src | |
| parent | b91455633b03add918af3eb166ac797fd6c95722 (diff) | |
| download | emacs-59f3c86659c061e2673eb0da0bc78528d30f8f76.tar.gz emacs-59f3c86659c061e2673eb0da0bc78528d30f8f76.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 62 |
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) | |||
| 3442 | if (! NILP (result)) | 3442 | if (! NILP (result)) |
| 3443 | return unbind_to (count, result); | 3443 | return unbind_to (count, result); |
| 3444 | } | 3444 | } |
| 3445 | { | ||
| 3446 | Lisp_Object result; | ||
| 3447 | ptrdiff_t nbytes = p - read_buffer; | ||
| 3448 | ptrdiff_t nchars | ||
| 3449 | = (multibyte | ||
| 3450 | ? multibyte_chars_in_text ((unsigned char *) read_buffer, | ||
| 3451 | nbytes) | ||
| 3452 | : nbytes); | ||
| 3453 | |||
| 3454 | if (uninterned_symbol) | ||
| 3455 | { | ||
| 3456 | Lisp_Object name | ||
| 3457 | = ((! NILP (Vpurify_flag) | ||
| 3458 | ? make_pure_string : make_specified_string) | ||
| 3459 | (read_buffer, nchars, nbytes, multibyte)); | ||
| 3460 | result = Fmake_symbol (name); | ||
| 3461 | } | ||
| 3462 | else | ||
| 3463 | { | ||
| 3464 | /* Don't create the string object for the name unless | ||
| 3465 | we're going to retain it in a new symbol. | ||
| 3445 | 3466 | ||
| 3446 | ptrdiff_t nbytes = p - read_buffer; | 3467 | Like intern_1 but supports multibyte names. */ |
| 3447 | ptrdiff_t nchars | 3468 | Lisp_Object obarray = check_obarray (Vobarray); |
| 3448 | = (multibyte | 3469 | Lisp_Object tem = oblookup (obarray, read_buffer, |
| 3449 | ? multibyte_chars_in_text ((unsigned char *) read_buffer, | 3470 | nchars, nbytes); |
| 3450 | nbytes) | 3471 | |
| 3451 | : nbytes); | 3472 | if (SYMBOLP (tem)) |
| 3452 | Lisp_Object name = ((uninterned_symbol && ! NILP (Vpurify_flag) | 3473 | result = tem; |
| 3453 | ? make_pure_string : make_specified_string) | 3474 | else |
| 3454 | (read_buffer, nchars, nbytes, multibyte)); | 3475 | { |
| 3455 | Lisp_Object result = (uninterned_symbol ? Fmake_symbol (name) | 3476 | Lisp_Object name |
| 3456 | : Fintern (name, Qnil)); | 3477 | = make_specified_string (read_buffer, nchars, nbytes, |
| 3457 | 3478 | multibyte); | |
| 3458 | if (EQ (Vread_with_symbol_positions, Qt) | 3479 | result = intern_driver (name, obarray, tem); |
| 3459 | || EQ (Vread_with_symbol_positions, readcharfun)) | 3480 | } |
| 3460 | Vread_symbol_positions_list | 3481 | } |
| 3461 | = Fcons (Fcons (result, make_number (start_position)), | 3482 | |
| 3462 | Vread_symbol_positions_list); | 3483 | if (EQ (Vread_with_symbol_positions, Qt) |
| 3463 | return unbind_to (count, result); | 3484 | || EQ (Vread_with_symbol_positions, readcharfun)) |
| 3485 | Vread_symbol_positions_list | ||
| 3486 | = Fcons (Fcons (result, make_number (start_position)), | ||
| 3487 | Vread_symbol_positions_list); | ||
| 3488 | return unbind_to (count, result); | ||
| 3489 | } | ||
| 3464 | } | 3490 | } |
| 3465 | } | 3491 | } |
| 3466 | } | 3492 | } |