bug-zile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-zile] [PATCH] term: optimise make_char_printable for ASCII


From: Gary V. Vaughan
Subject: [Bug-zile] [PATCH] term: optimise make_char_printable for ASCII
Date: Tue, 13 Dec 2011 12:32:56 +0700

Since this code already assumes ASCII in that \01 through \032 will
map to A-Z contiguously, we can optimise it some more for \0 and \033
which are in the same range.

Okay to push?

In ASCII, `@' precedes 'A' and '[' follows 'Z', so there's no need
to make additional checks just outside the A-Z range for printing
`^@' (\0) and `^[' (\033).
* term_redisplay.c (make_char_printable): Save some comparisons
and a subtraction in the inner display loop when determining the
 display string for non-printable characters.
---
 src/term_redisplay.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/term_redisplay.c b/src/term_redisplay.c
index a133913..dd24779 100644
--- a/src/term_redisplay.c
+++ b/src/term_redisplay.c
@@ -35,12 +35,8 @@ make_char_printable (char c, int x, int cur_tab_width)
 {
   if (c == '\t')
     return xasprintf ("%*s", cur_tab_width - x % cur_tab_width, "");
-  if (c == '\0')
-    return "^@";
-  else if (c > 0 && c <= '\32')
-    return xasprintf ("^%c", 'A' + c - 1);
-  else if (c == '\33')
-    return "^[";
+  if (c >= 0 && c <= '\33')
+    return xasprintf ("^%c", '@' + c);
   else
     return xasprintf ("\\%o", c & 0xff);
 }
-- 
1.7.8

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]