aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-05-20 03:58:55 +0300
committerZyX <kp-pav@yandex.ru>2017-05-20 04:21:00 +0300
commit9ec2bf26ce727f7bd114905f106f2d62762e3d93 (patch)
tree0d2acd6c1bd58076326f7bd1cb77470aa5e32229 /src
parent37a77506b0ddbc9dab7dd5984c843258e623b3f4 (diff)
downloadrneovim-9ec2bf26ce727f7bd114905f106f2d62762e3d93.tar.gz
rneovim-9ec2bf26ce727f7bd114905f106f2d62762e3d93.tar.bz2
rneovim-9ec2bf26ce727f7bd114905f106f2d62762e3d93.zip
getchar: Eliminate two-iteration loop
Diffstat (limited to 'src')
-rw-r--r--src/nvim/getchar.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 79b95272de..c3c393f1ec 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -3794,8 +3794,7 @@ makemap (
char *cmd;
int abbr;
int hash;
- int did_cpo = FALSE;
- int i;
+ bool did_cpo = false;
validate_maphash();
@@ -3923,13 +3922,15 @@ makemap (
/* When outputting <> form, need to make sure that 'cpo'
* is set to the Vim default. */
if (!did_cpo) {
- if (*mp->m_str == NUL) /* will use <Nop> */
- did_cpo = TRUE;
- else
- for (i = 0; i < 2; ++i)
- for (p = (i ? mp->m_str : mp->m_keys); *p; ++p)
- if (*p == K_SPECIAL || *p == NL)
- did_cpo = TRUE;
+ if (*mp->m_str == NUL) { // Will use <Nop>.
+ did_cpo = true;
+ } else {
+ const char specials[] = { (char)(uint8_t)K_SPECIAL, NL, NUL };
+ if (strpbrk((const char *)mp->m_str, specials) != NULL
+ || strpbrk((const char *)mp->m_keys, specials) != NULL) {
+ did_cpo = true;
+ }
+ }
if (did_cpo) {
if (fprintf(fd, "let s:cpo_save=&cpo") < 0
|| put_eol(fd) < 0