diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-04 14:29:58 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-04 14:45:08 -0700 |
commit | 3db388b0bf83d3138562f09ce25fab8ba89bcc81 (patch) | |
tree | ff86fa2e529cdd9187a12e88d193b4416d60c26e /etc/NEWS | |
parent | 4e0b67ed27114fa2cbebca32567089fd8fa78425 (diff) | |
download | emacs-3db388b0bf83d3138562f09ce25fab8ba89bcc81.tar.gz |
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 'etc/NEWS')
-rw-r--r-- | etc/NEWS | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1556,6 +1556,13 @@ Emacs integers with %e, %f, or %g conversions. For example, on these hosts (eql N (string-to-number (format "%.0f" N))) now returns t for all Emacs integers N. ++++ +** 'format' is no longer documented to return a newly-allocated string. +This documentation was not correct, as (eq x (format x)) returned t +when x was the empty string. 'format' now takes advantage of the doc +change to avoid making copies of strings in common cases like (format +"foo") and (format "%s" "foo"). + --- ** Calls that accept floating-point integers (for use on hosts with limited integer range) now signal an error if arguments are not |