diff options
| author | Paul Eggert | 2017-10-04 14:29:58 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-10-04 14:45:08 -0700 |
| commit | 3db388b0bf83d3138562f09ce25fab8ba89bcc81 (patch) | |
| tree | ff86fa2e529cdd9187a12e88d193b4416d60c26e /src/callint.c | |
| parent | 4e0b67ed27114fa2cbebca32567089fd8fa78425 (diff) | |
| download | emacs-3db388b0bf83d3138562f09ce25fab8ba89bcc81.tar.gz emacs-3db388b0bf83d3138562f09ce25fab8ba89bcc81.zip | |
Speed up (format "%s" STRING) and the like
Although the Lisp manual said that ‘format’ returns a
newly-allocated string, this was not true for a few cases like
(format "%s" ""), and fixing the documentation to allow reuse of
arguments lets us improve performance in common cases like
(format "foo") and (format "%s" "foo") (Bug#28625).
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Say that the result of ‘format’ might not be newly allocated.
* src/callint.c (Fcall_interactively):
* src/dbusbind.c (XD_OBJECT_TO_STRING):
* src/editfns.c (Fmessage, Fmessage_box):
* src/xdisp.c (vadd_to_log, Ftrace_to_stderr):
Just use Fformat or Fformat_message, as that’s simpler and no
longer makes unnecessary copies.
* src/editfns.c (styled_format): Remove last argument, as it
is no longer needed: all callers now want it to behave as if it
were true. All remaining callers changed. Make this function
static again. Simplify the function now that we no longer
need to worry about whether the optimization is allowed.
Diffstat (limited to 'src/callint.c')
| -rw-r--r-- | src/callint.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/callint.c b/src/callint.c index 469205cc380..5d88082e38d 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -272,7 +272,7 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 272 | { | 272 | { |
| 273 | /* `args' will contain the array of arguments to pass to the function. | 273 | /* `args' will contain the array of arguments to pass to the function. |
| 274 | `visargs' will contain the same list but in a nicer form, so that if we | 274 | `visargs' will contain the same list but in a nicer form, so that if we |
| 275 | pass it to styled_format it will be understandable to a human. */ | 275 | pass it to Fformat_message it will be understandable to a human. */ |
| 276 | Lisp_Object *args, *visargs; | 276 | Lisp_Object *args, *visargs; |
| 277 | Lisp_Object specs; | 277 | Lisp_Object specs; |
| 278 | Lisp_Object filter_specs; | 278 | Lisp_Object filter_specs; |
| @@ -502,7 +502,7 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 502 | for (i = 2; *tem; i++) | 502 | for (i = 2; *tem; i++) |
| 503 | { | 503 | { |
| 504 | visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); | 504 | visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); |
| 505 | callint_message = styled_format (i - 1, visargs + 1, true, false); | 505 | callint_message = Fformat_message (i - 1, visargs + 1); |
| 506 | 506 | ||
| 507 | switch (*tem) | 507 | switch (*tem) |
| 508 | { | 508 | { |