]> git.eshelyaron.com Git - emacs.git/commit
Improve doprnt performance
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Oct 2020 20:41:01 +0000 (13:41 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Oct 2020 21:00:13 +0000 (14:00 -0700)
commitd35d5c7ecde9b5003c3b21f773570800542664fa
tree6b61cc92bb2a7b0d212e876c3cf62a077e725954
parentc3835bd3803e5f395c4ebf0b2585cc9272173548
Improve doprnt performance

This patch implements some of my suggestions in Bug#8545,
with further changes suggested by Eli Zaretskii (Bug#43439).
* src/doprnt.c: Improve comments.
(SIZE_BOUND_EXTRA): Now at top level, for parse_format_integer.
(parse_format_integer): New static function, containing some of
the old doprnt.  Fix a bug that caused doprnt to infloop on
formats like "%10s" that Emacs does not use.  We could simplify
doprnt further if we dropped support for these never-used formats.
(doprnt_nul): New function.
(doprnt): Use it.  Change doprnt API to exit when either it finds NUL
or reaches the character specified by FORMAT_END.  In the typical case
where FORMAT_END is null, take just one pass over FORMAT, not two.
Assume C99 to make code clearer.  Do not use malloc or alloca to
allocate a copy of the format FMTCPY; instead, use a small fixed-size
array FMTSTAR, and use '*' in that array to represent width and
precision, passing them as separate int arguments.  Use eassume to
pacify GCC in switch statements.
src/doprnt.c