summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-09-26 16:31:57 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-09-26 16:36:43 -0700
commit0e82fa34163dba21121e3a9cffa7f896c81c4d93 (patch)
tree16c728aa616dae256d429060e257313dcfe4dbde /src/xdisp.c
parent98a37e60142340b9c2b4e6b17c373f4ae6a2d8b4 (diff)
downloademacs-0e82fa34163dba21121e3a9cffa7f896c81c4d93.tar.gz
Avoid some unnecessary copying in Fformat etc.
This patch is just for performance; it should not affect behavior. On my platform, it made the microbenchmark (format "%S" load-path) run about 45% faster. It should also speed up calls like (message "%s" STRING). * 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): Use styled_format instead of Fformat or Fformat_message, to avoid unnecessary copying. * src/editfns.c (styled_format): New arg NEW_RESULT. All uses changed. Reuse an input string if it has the right value and if !NEW_RESULT. * src/lisp.h (style_format): New decl.
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 141275f15a0..86164eb9f6f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10194,7 +10194,7 @@ vadd_to_log (char const *format, va_list ap)
for (ptrdiff_t i = 1; i <= nargs; i++)
args[i] = va_arg (ap, Lisp_Object);
Lisp_Object msg = Qnil;
- msg = Fformat_message (nargs, args);
+ msg = styled_format (nargs, args, true, false);
ptrdiff_t len = SBYTES (msg) + 1;
USE_SAFE_ALLOCA;
@@ -19525,7 +19525,7 @@ DEFUN ("trace-to-stderr", Ftrace_to_stderr, Strace_to_stderr, 1, MANY, "",
usage: (trace-to-stderr STRING &rest OBJECTS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
- Lisp_Object s = Fformat (nargs, args);
+ Lisp_Object s = styled_format (nargs, args, false, false);
fwrite (SDATA (s), 1, SBYTES (s), stderr);
return Qnil;
}