aboutsummaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorPaul Eggert2017-10-04 14:29:58 -0700
committerPaul Eggert2017-10-04 14:45:08 -0700
commit3db388b0bf83d3138562f09ce25fab8ba89bcc81 (patch)
treeff86fa2e529cdd9187a12e88d193b4416d60c26e /etc
parent4e0b67ed27114fa2cbebca32567089fd8fa78425 (diff)
downloademacs-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 'etc')
-rw-r--r--etc/NEWS7
1 files changed, 7 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 62d2450f9a3..62a9ea2181c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1556,6 +1556,13 @@ Emacs integers with %e, %f, or %g conversions. For example, on these
1556hosts (eql N (string-to-number (format "%.0f" N))) now returns t for 1556hosts (eql N (string-to-number (format "%.0f" N))) now returns t for
1557all Emacs integers N. 1557all Emacs integers N.
1558 1558
1559+++
1560** 'format' is no longer documented to return a newly-allocated string.
1561This documentation was not correct, as (eq x (format x)) returned t
1562when x was the empty string. 'format' now takes advantage of the doc
1563change to avoid making copies of strings in common cases like (format
1564"foo") and (format "%s" "foo").
1565
1559--- 1566---
1560** Calls that accept floating-point integers (for use on hosts with 1567** Calls that accept floating-point integers (for use on hosts with
1561limited integer range) now signal an error if arguments are not 1568limited integer range) now signal an error if arguments are not