diff options
| author | Paul Eggert | 2016-04-04 10:30:41 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-04 10:31:25 -0700 |
| commit | 17cb263adb7c37803140604f0a2e4df8a38fbcff (patch) | |
| tree | bd57929386123132847718e2d30a528c8b19d1a3 /src/lisp.h | |
| parent | 0322457e2bec0b9409a03887a8235dbe14e357f4 (diff) | |
| download | emacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.tar.gz emacs-17cb263adb7c37803140604f0a2e4df8a38fbcff.zip | |
New C macro AUTO_STRING_WITH_LEN
Put a bit less pressure on the garbage collector by defining a
macro that is like AUTO_STRING but also allows null bytes in strings,
and by extending AUTO_STRING to work with any unibyte string.
* src/alloc.c (verify_ascii): Remove; all uses removed.
AUTO_STRING can now be used on non-ASCII unibyte strings.
* src/lisp.h (AUTO_STRING): Now allows non-ASCII unibyte strings.
(AUTO_STRING_WITH_LEN): New macro.
* src/coding.c (from_unicode_buffer):
* src/editfns.c (format_time_string):
* src/emacs-module.c (module_make_string, module_format_fun_env):
* src/fileio.c (Fexpand_file_name):
* src/font.c (font_parse_family_registry):
* src/ftfont.c (ftfont_get_charset):
* src/keymap.c (silly_event_symbol_error):
* src/menu.c (single_menu_item):
* src/sysdep.c (system_process_attributes):
Use AUTO_STRING_WITH_LEN if possible.
* src/emacs-module.c (module_make_function):
* src/fileio.c (report_file_errno, report_file_notify_error):
* src/fns.c (Flocale_info):
* src/sysdep.c (system_process_attributes):
Use AUTO_STRING if possible. This is doable more often now
that AUTO_STRING works on any unibyte string.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lisp.h b/src/lisp.h index 65335fbc052..170da67c61c 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4609,27 +4609,29 @@ enum | |||
| 4609 | STACK_CONS (d, Qnil)))) \ | 4609 | STACK_CONS (d, Qnil)))) \ |
| 4610 | : list4 (a, b, c, d)) | 4610 | : list4 (a, b, c, d)) |
| 4611 | 4611 | ||
| 4612 | /* Check whether stack-allocated strings are ASCII-only. */ | 4612 | /* Declare NAME as an auto Lisp string if possible, a GC-based one if not. |
| 4613 | Take its unibyte value from the null-terminated string STR, | ||
| 4614 | an expression that should not have side effects. | ||
| 4615 | STR's value is not necessarily copied. The resulting Lisp string | ||
| 4616 | should not be modified or made visible to user code. */ | ||
| 4613 | 4617 | ||
| 4614 | #if defined (ENABLE_CHECKING) && USE_STACK_LISP_OBJECTS | 4618 | #define AUTO_STRING(name, str) \ |
| 4615 | extern const char *verify_ascii (const char *); | 4619 | AUTO_STRING_WITH_LEN (name, str, strlen (str)) |
| 4616 | #else | ||
| 4617 | # define verify_ascii(str) (str) | ||
| 4618 | #endif | ||
| 4619 | 4620 | ||
| 4620 | /* Declare NAME as an auto Lisp string if possible, a GC-based one if not. | 4621 | /* Declare NAME as an auto Lisp string if possible, a GC-based one if not. |
| 4621 | Take its value from STR. STR is not necessarily copied and should | 4622 | Take its unibyte value from the null-terminated string STR with length LEN. |
| 4622 | contain only ASCII characters. The resulting Lisp string should | 4623 | STR may have side effects and may contain null bytes. |
| 4623 | not be modified or made visible to user code. */ | 4624 | STR's value is not necessarily copied. The resulting Lisp string |
| 4625 | should not be modified or made visible to user code. */ | ||
| 4624 | 4626 | ||
| 4625 | #define AUTO_STRING(name, str) \ | 4627 | #define AUTO_STRING_WITH_LEN(name, str, len) \ |
| 4626 | Lisp_Object name = \ | 4628 | Lisp_Object name = \ |
| 4627 | (USE_STACK_STRING \ | 4629 | (USE_STACK_STRING \ |
| 4628 | ? (make_lisp_ptr \ | 4630 | ? (make_lisp_ptr \ |
| 4629 | ((&(union Aligned_String) \ | 4631 | ((&(union Aligned_String) \ |
| 4630 | {{strlen (str), -1, 0, (unsigned char *) verify_ascii (str)}}.s), \ | 4632 | {{len, -1, 0, (unsigned char *) (str)}}.s), \ |
| 4631 | Lisp_String)) \ | 4633 | Lisp_String)) \ |
| 4632 | : build_string (verify_ascii (str))) | 4634 | : make_unibyte_string (str, len)) |
| 4633 | 4635 | ||
| 4634 | /* Loop over all tails of a list, checking for cycles. | 4636 | /* Loop over all tails of a list, checking for cycles. |
| 4635 | FIXME: Make tortoise and n internal declarations. | 4637 | FIXME: Make tortoise and n internal declarations. |