diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-28 21:48:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-28 21:48:50 +0100 |
| commit | 33f99431dcd4e71bdb97b6a8d73ac2a76cd7422e (patch) | |
| tree | 69203d15b4e1d67dc7f4de0beabe4cd621dc1f52 /src/nvim/ex_docmd.c | |
| parent | 76204da1f8ed63f7b0ef15ad7c71ce6e2e58d8fb (diff) | |
| parent | 63025a1d65bf7dbfcf4f3d543c1da9b0d34ebd56 (diff) | |
| download | rneovim-33f99431dcd4e71bdb97b6a8d73ac2a76cd7422e.tar.gz rneovim-33f99431dcd4e71bdb97b6a8d73ac2a76cd7422e.tar.bz2 rneovim-33f99431dcd4e71bdb97b6a8d73ac2a76cd7422e.zip | |
Merge #9803 from janlazo/vim-8.0.0504
Benchmarked using RelWithDebInfo build and the `:Time` command from
https://github.com/tpope/vim-scriptease .
:Time for i in range(0,99999)|call exists(':abbreviate')|endfor
- before (8698830cbd73): 0.431 seconds
- after (63025a1d65bf): 0.345 seconds
- Vim 8.1.1005 : 0.361 seconds
Diffstat (limited to 'src/nvim/ex_docmd.c')
| -rw-r--r-- | src/nvim/ex_docmd.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index fbe41f9914..037b5dec7f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2263,8 +2263,11 @@ static char_u * do_one_cmd(char_u **cmdlinep, need_rethrow = check_cstack = FALSE; doend: - if (curwin->w_cursor.lnum == 0) /* can happen with zero line number */ + // can happen with zero line number + if (curwin->w_cursor.lnum == 0) { curwin->w_cursor.lnum = 1; + curwin->w_cursor.col = 0; + } if (errormsg != NULL && *errormsg != NUL && !did_emsg) { if (flags & DOCMD_VERBOSE) { @@ -2440,10 +2443,24 @@ static char_u *find_command(exarg_T *eap, int *full) } } - if (ASCII_ISLOWER(*eap->cmd)) - eap->cmdidx = cmdidxs[CharOrdLow(*eap->cmd)]; - else - eap->cmdidx = cmdidxs[26]; + if (ASCII_ISLOWER(eap->cmd[0])) { + const int c1 = eap->cmd[0]; + const int c2 = eap->cmd[1]; + + if (command_count != (int)CMD_SIZE) { + iemsg((char *)_("E943: Command table needs to be updated, run 'make'")); + getout(1); + } + + // Use a precomputed index for fast look-up in cmdnames[] + // taking into account the first 2 letters of eap->cmd. + eap->cmdidx = cmdidxs1[CharOrdLow(c1)]; + if (ASCII_ISLOWER(c2)) { + eap->cmdidx += cmdidxs2[CharOrdLow(c1)][CharOrdLow(c2)]; + } + } else { + eap->cmdidx = CMD_bang; + } for (; (int)eap->cmdidx < (int)CMD_SIZE; eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) |