summaryrefslogtreecommitdiff
path: root/src/ccl.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-06-25 19:33:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-06-25 19:33:51 -0700
commit99027bdd81f63ea690394a153ef49a08f55e498d (patch)
treeb7b7083784549ae09d9e688441168627262d4b6d /src/ccl.c
parentcf38a720e81b545f90dc7be81891d94df6ed059a (diff)
downloademacs-99027bdd81f63ea690394a153ef49a08f55e498d.tar.gz
emacs-99027bdd81f63ea690394a153ef49a08f55e498d.tar.bz2
emacs-99027bdd81f63ea690394a153ef49a08f55e498d.zip
Use sprintf return value instead of invoking strlen on result.
In the old days this wasn't portable, since some sprintf implementations returned char *. But they died out years ago and Emacs already assumes sprintf returns int. Similarly for float_to_string. This patch speeds up (number-to-string 1000) by 3% on Fedora 15 x86-64. * ccl.c (ccl_driver): * character.c (string_escape_byte8): * data.c (Fnumber_to_string): * doprnt.c (doprnt): * print.c (print_object): * xdisp.c (message_dolog): * xfns.c (syms_of_xfns): Use sprintf or float_to_string result to avoid need to call strlen. * data.c (Fnumber_to_string): Use make_unibyte_string, since the string must be ASCII. * lisp.h, print.c (float_to_string): Now returns int length. * term.c (produce_glyphless_glyph): Use sprintf result rather than recomputing it.
Diffstat (limited to 'src/ccl.c')
-rw-r--r--src/ccl.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ccl.c b/src/ccl.c
index 163d01fe283..63ceaeadad5 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1729,14 +1729,14 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
switch (ccl->status)
{
case CCL_STAT_INVALID_CMD:
- sprintf (msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
- code & 0x1F, code, this_ic);
+ msglen = sprintf (msg,
+ "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
+ code & 0x1F, code, this_ic);
#ifdef CCL_DEBUG
{
int i = ccl_backtrace_idx - 1;
int j;
- msglen = strlen (msg);
if (dst + msglen <= (dst_bytes ? dst_end : src))
{
memcpy (dst, msg, msglen);
@@ -1748,8 +1748,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
if (ccl_backtrace_table[i] == 0)
break;
- sprintf (msg, " %d", ccl_backtrace_table[i]);
- msglen = strlen (msg);
+ msglen = sprintf (msg, " %d", ccl_backtrace_table[i]);
if (dst + msglen > (dst_bytes ? dst_end : src))
break;
memcpy (dst, msg, msglen);
@@ -1761,15 +1760,13 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
break;
case CCL_STAT_QUIT:
- if (! ccl->quit_silently)
- sprintf (msg, "\nCCL: Quitted.");
+ msglen = ccl->quit_silently ? 0 : sprintf (msg, "\nCCL: Quitted.");
break;
default:
- sprintf (msg, "\nCCL: Unknown error type (%d)", ccl->status);
+ msglen = sprintf (msg, "\nCCL: Unknown error type (%d)", ccl->status);
}
- msglen = strlen (msg);
if (msglen <= dst_end - dst)
{
for (i = 0; i < msglen; i++)