aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termptyesc.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-12-18 15:16:54 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-12-18 15:32:02 +0900
commit8cfa269b54657ed390ee6953589dbbdd27041e07 (patch)
tree3debadda919c4a8bbce4458ea57c1d6efd8793b9 /src/bin/termptyesc.c
parenttysend status - fix focus after close/cancel (diff)
downloadterminology-8cfa269b54657ed390ee6953589dbbdd27041e07.tar.gz
tysend - optimize sending - pretty much double the speed
yes. it's still inefficient because we transfer in ascii-ized nibbles (4 bits) within a utf8 stream that becoems a 32bit per char unicode buffer then back to utf8 before being "parsed" as a command etc. etc. ... it's not brilliant for transferring binary data. it's horrible actually. but at least i've dropped overhead for some of the large escape handling code. this increases buffer size to 32k per block sent, and have the terminal escape/buffer handling track if a zero byte exists in the buffer at all to avoid hunting for one if none is there, making terminology escape handling much more efficient for large escapes and buffers.
Diffstat (limited to 'src/bin/termptyesc.c')
-rw-r--r--src/bin/termptyesc.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 800cdce..06c418b 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1767,38 +1767,27 @@ err:
static int
_handle_esc_terminology(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
- Eina_Unicode *cc;
- Eina_Unicode *buf, bufsmall[1024], *b;
+ Eina_Unicode *cc, *cc_zero = NULL;
+ const Eina_Unicode *buf;
char *cmd;
int blen = 0;
Config *config;
+ if (!ty->buf_have_zero) return 0;
+
config = termio_config_get(ty->obj);
cc = (Eina_Unicode *)c;
+ if ((cc < ce) && (*cc == 0x0)) cc_zero = cc;
while ((cc < ce) && (*cc != 0x0))
{
blen++;
cc++;
}
- buf = bufsmall;
- if (blen > (int)((sizeof(bufsmall) / sizeof(Eina_Unicode)) - 40))
- buf = malloc((blen * sizeof(Eina_Unicode)) + 40);
- cc = (Eina_Unicode *)c;
- b = buf;
- while ((cc < ce) && (*cc != 0x0))
- {
- *b = *cc;
- b++;
- cc++;
- }
- if ((cc < ce) && (*cc == 0x0)) cc++;
- else
- {
- if (buf != bufsmall) free(buf);
- return 0;
- }
- *b = 0;
+ if ((cc < ce) && (*cc == 0x0)) cc_zero = cc;
+ if (!cc_zero) return 0;
+ buf = (Eina_Unicode *)c;
+ cc = cc_zero;
// commands are stored in the buffer, 0 bytes not allowed (end marker)
cmd = eina_unicode_unicode_to_utf8(buf, NULL);
@@ -1810,7 +1799,6 @@ _handle_esc_terminology(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *
ty->cur_cmd = NULL;
free(cmd);
- if (buf != bufsmall) free(buf);
return cc - c;
}