Mercurial > vim
diff src/map.c @ 31728:238ca27dbfd2 v9.0.1196
patch 9.0.1196: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Jan 14 12:32:28 2023 +0000
patch 9.0.1196: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11813)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 Jan 2023 13:45:04 +0100 |
parents | d9263e7a0570 |
children | e16361210675 |
line wrap: on
line diff
--- a/src/map.c +++ b/src/map.c @@ -67,11 +67,11 @@ is_maphash_valid(void) static void validate_maphash(void) { - if (!maphash_valid) - { - CLEAR_FIELD(maphash); - maphash_valid = TRUE; - } + if (maphash_valid) + return; + + CLEAR_FIELD(maphash); + maphash_valid = TRUE; } /* @@ -581,8 +581,8 @@ do_map( // needs to be freed later (*keys_buf and *arg_buf). // replace_termcodes() also removes CTRL-Vs and sometimes backslashes. // If something like <C-H> is simplified to 0x08 then mark it as simplified - // and also add a n entry with a modifier, which will work when - // modifyOtherKeys is working. + // and also add an entry with a modifier, which will work when using a key + // protocol. if (haskey) { char_u *new_keys; @@ -1843,32 +1843,33 @@ vim_strsave_escape_csi(char_u *p) // illegal utf-8 byte: // 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER res = alloc(STRLEN(p) * 4 + 1); - if (res != NULL) + if (res == NULL) + return NULL; + + d = res; + for (s = p; *s != NUL; ) { - d = res; - for (s = p; *s != NUL; ) - { - if ((s[0] == K_SPECIAL + if ((s[0] == K_SPECIAL #ifdef FEAT_GUI || (gui.in_use && s[0] == CSI) #endif - ) && s[1] != NUL && s[2] != NUL) - { - // Copy special key unmodified. - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - } - else - { - // Add character, possibly multi-byte to destination, escaping - // CSI and K_SPECIAL. Be careful, it can be an illegal byte! - d = add_char2buf(PTR2CHAR(s), d); - s += MB_CPTR2LEN(s); - } + ) && s[1] != NUL && s[2] != NUL) + { + // Copy special key unmodified. + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; } - *d = NUL; + else + { + // Add character, possibly multi-byte to destination, escaping + // CSI and K_SPECIAL. Be careful, it can be an illegal byte! + d = add_char2buf(PTR2CHAR(s), d); + s += MB_CPTR2LEN(s); + } } + *d = NUL; + return res; }