diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-12-14 13:42:10 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-12-14 13:42:10 -0500 |
commit | ec6afbf4e621bfcfde903d15744dc0c61f80097d (patch) | |
tree | 94fd08577b5eed003b6f7eb3a7bcafcac7f20a66 /src/nvim/getchar.c | |
parent | 64a32d55c59188f1e922ca438fdb2d65caa06665 (diff) | |
parent | 0bc40e660c0a74776ace86ad5e393755523c3803 (diff) | |
download | rneovim-ec6afbf4e621bfcfde903d15744dc0c61f80097d.tar.gz rneovim-ec6afbf4e621bfcfde903d15744dc0c61f80097d.tar.bz2 rneovim-ec6afbf4e621bfcfde903d15744dc0c61f80097d.zip |
Merge pull request #1661 from philix/early_exit
Reduce indentation level by early returning or continuing loop
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5dec7e38fd..1d648cb9e9 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -680,33 +680,34 @@ static int read_redo(int init, int old_redo) p = bp->b_str; return OK; } - if ((c = *p) != NUL) { - /* Reverse the conversion done by add_char_buff() */ - /* For a multi-byte character get all the bytes and return the - * converted character. */ - if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) - n = MB_BYTE2LEN_CHECK(c); - else - n = 1; - for (i = 0;; ++i) { - if (c == K_SPECIAL) { /* special key or escaped K_SPECIAL */ - c = TO_SPECIAL(p[1], p[2]); - p += 2; - } - if (*++p == NUL && bp->b_next != NULL) { - bp = bp->b_next; - p = bp->b_str; - } - buf[i] = c; - if (i == n - 1) { /* last byte of a character */ - if (n != 1) - c = (*mb_ptr2char)(buf); - break; - } - c = *p; - if (c == NUL) /* cannot happen? */ - break; + if ((c = *p) == NUL) { + return c; + } + /* Reverse the conversion done by add_char_buff() */ + /* For a multi-byte character get all the bytes and return the + * converted character. */ + if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) + n = MB_BYTE2LEN_CHECK(c); + else + n = 1; + for (i = 0;; ++i) { + if (c == K_SPECIAL) { /* special key or escaped K_SPECIAL */ + c = TO_SPECIAL(p[1], p[2]); + p += 2; } + if (*++p == NUL && bp->b_next != NULL) { + bp = bp->b_next; + p = bp->b_str; + } + buf[i] = c; + if (i == n - 1) { /* last byte of a character */ + if (n != 1) + c = (*mb_ptr2char)(buf); + break; + } + c = *p; + if (c == NUL) /* cannot happen? */ + break; } return c; |