Avoid some unnecessary copying in Fformat etc.
commit0e82fa34163dba21121e3a9cffa7f896c81c4d93
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 23:31:57 +0000 (26 16:31 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 23:36:43 +0000 (26 16:36 -0700)
tree16c728aa616dae256d429060e257313dcfe4dbde
parent98a37e60142340b9c2b4e6b17c373f4ae6a2d8b4
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.
src/callint.c
src/dbusbind.c
src/editfns.c
src/lisp.h
src/xdisp.c