From 5f32ac13c8b42e2a4eaadea1c4d0888ef341c9cd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 20 Jun 2019 00:01:06 -0700 Subject: [PATCH] Minor putc tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/emacs-module.c (module_abort): * src/xdisp.c (vmessage): Prefer fputc to putc, since speed isn’t crucial here. * src/region-cache.c (pp_cache) [ENABLE_CHECKING]: Simplify. --- src/emacs-module.c | 2 +- src/region-cache.c | 16 +++++----------- src/xdisp.c | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/emacs-module.c b/src/emacs-module.c index 907a5d8225a..c856663d2ff 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -1304,7 +1304,7 @@ module_abort (const char *format, ...) va_start (args, format); vfprintf (stderr, format, args); va_end (args); - putc ('\n', stderr); + fputc ('\n', stderr); fflush (NULL); emacs_abort (); } diff --git a/src/region-cache.c b/src/region-cache.c index d2e3d94829b..57a26f2fa64 100644 --- a/src/region-cache.c +++ b/src/region-cache.c @@ -759,7 +759,6 @@ void pp_cache (struct region_cache *) EXTERNALLY_VISIBLE; void pp_cache (struct region_cache *c) { - ptrdiff_t i; ptrdiff_t beg_u = c->buffer_beg + c->beg_unchanged; ptrdiff_t end_u = c->buffer_end - c->end_unchanged; @@ -768,19 +767,14 @@ pp_cache (struct region_cache *c) c->buffer_beg, c->buffer_end, beg_u, end_u); - for (i = 0; i < c->cache_len; i++) + for (ptrdiff_t i = 0; i < c->cache_len; i++) { ptrdiff_t pos = BOUNDARY_POS (c, i); - putc (((pos < beg_u) ? 'v' - : (pos == beg_u) ? '-' - : ' '), - stderr); - putc (((pos > end_u) ? '^' - : (pos == end_u) ? '-' - : ' '), - stderr); - fprintf (stderr, "%"pD"d : %d\n", pos, BOUNDARY_VALUE (c, i)); + fprintf (stderr, "%c%c%"pD"d : %d\n", + pos < beg_u ? 'v' : pos == beg_u ? '-' : ' ', + pos > end_u ? '^' : pos == end_u ? '-' : ' ', + pos, BOUNDARY_VALUE (c, i)); } } diff --git a/src/xdisp.c b/src/xdisp.c index dc5101d5aca..945174e09c5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10845,11 +10845,11 @@ vmessage (const char *m, va_list ap) if (m) { if (noninteractive_need_newline) - putc ('\n', stderr); + fputc ('\n', stderr); noninteractive_need_newline = false; vfprintf (stderr, m, ap); if (!cursor_in_echo_area) - fprintf (stderr, "\n"); + fputc ('\n', stderr); fflush (stderr); } } -- 2.39.2