From 7db2f658e87278885a137ac2b0b88df6a1b546cb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 01:38:43 +0300 Subject: ex_getln: Do not do arabic shaping unless needed Should speed up execution without arabic characters a bit, slowing down with arabic characters. More necessary, this allows coloring prompt without caring about arabic shaping at the first iteration. --- src/nvim/ex_getln.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 013f936137..632f125b45 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2182,6 +2182,22 @@ static void draw_cmdline(int start, int len) } } } else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { + bool do_arabicshape = false; + int mb_l; + for (int i = start; i < start + len; i += mb_l) { + char_u *p = ccline.cmdbuff + i; + int u8cc[MAX_MCO]; + int u8c = utfc_ptr2char_len(p, u8cc, start + len - i); + mb_l = utfc_ptr2len_len(p, start + len - i); + if (arabic_char(u8c)) { + do_arabicshape = true; + break; + } + } + if (!do_arabicshape) { + goto draw_cmdline_no_arabicshape; + } + static int buflen = 0; // Do arabic shaping into a temporary buffer. This is very @@ -2201,7 +2217,6 @@ static void draw_cmdline(int start, int len) newlen = 1; } - int mb_l; int prev_c = 0; int prev_c1 = 0; for (int i = start; i < start + len; i += mb_l) { @@ -2256,6 +2271,7 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { +draw_cmdline_no_arabicshape: msg_outtrans_len(ccline.cmdbuff + start, len); } } -- cgit