aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-06-24 15:06:56 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-11-14 03:24:10 +0100
commit89764adf8e7154fbe1b9bd82e26d7aa180d2a12f (patch)
tree2eaf384dc71f42ccaa4a694ed4680e798faf281c
parent59f1a85d1bc36a34cfcacb4faa993b82a965a109 (diff)
downloadhex-89764adf8e7154fbe1b9bd82e26d7aa180d2a12f.tar.gz
hex-89764adf8e7154fbe1b9bd82e26d7aa180d2a12f.tar.xz
hex-89764adf8e7154fbe1b9bd82e26d7aa180d2a12f.zip
Improve redrawing performance
-rw-r--r--hex.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hex.c b/hex.c
index a85a41b..cef9b64 100644
--- a/hex.c
+++ b/hex.c
@@ -542,6 +542,7 @@ app_make_row (struct row_buffer *buf, int64_t addr, int attrs)
row_buffer_append (&ascii, " ", attrs);
int64_t end_addr = g_ctx.data_offset + g_ctx.data_len;
+ const char *hexa = "0123456789abcdef";
for (int x = 0; x < ROW_SIZE; x++)
{
if (x % 8 == 0) row_buffer_append (buf, " ", attrs);
@@ -568,9 +569,9 @@ app_make_row (struct row_buffer *buf, int64_t addr, int attrs)
// TODO: leave it up to the user to decide what should be colored
uint8_t cell = g_ctx.data[cell_addr - g_ctx.data_offset];
- char *hex = xstrdup_printf ("%02x", cell);
- row_buffer_append (buf, hex, attrs | highlight);
- free (hex);
+ row_buffer_append (buf,
+ (char[3]) { hexa[cell >> 4], hexa[cell & 7], 0 },
+ attrs | highlight);
char s[2] = { (cell >= 32 && cell < 127) ? cell : '.', 0 };
row_buffer_append (&ascii, s, attrs_mark | highlight);