summaryrefslogtreecommitdiff
path: root/src/character.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/character.c
parentcf38a720e81b545f90dc7be81891d94df6ed059a (diff)
downloademacs-99027bdd81f63ea690394a153ef49a08f55e498d.tar.gz
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/character.c')
-rw-r--r--src/character.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/character.c b/src/character.c
index fbd23409d08..da182488033 100644
--- a/src/character.c
+++ b/src/character.c
@@ -867,8 +867,7 @@ string_escape_byte8 (Lisp_Object string)
{
c = STRING_CHAR_ADVANCE (src);
c = CHAR_TO_BYTE8 (c);
- sprintf ((char *) dst, "\\%03o", c);
- dst += 4;
+ dst += sprintf ((char *) dst, "\\%03o", c);
}
else
while (len--) *dst++ = *src++;
@@ -878,10 +877,7 @@ string_escape_byte8 (Lisp_Object string)
{
c = *src++;
if (c >= 0x80)
- {
- sprintf ((char *) dst, "\\%03o", c);
- dst += 4;
- }
+ dst += sprintf ((char *) dst, "\\%03o", c);
else
*dst++ = c;
}