diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-14 12:32:28 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-14 12:32:28 +0000 |
commit | e8575988969579f9e1439181ae338b2ff74054a8 (patch) | |
tree | f4c8a1242cb67b073bb0e375740c764c2136af21 /src/map.c | |
parent | 378e6c03f98efc88e8c2675e05a548f9bb7889a1 (diff) |
patch 9.0.1196: code is indented more than necessaryv9.0.1196
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11813)
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 55 |
1 files changed, 28 insertions, 27 deletions
@@ -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++; + } + 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; } + *d = NUL; + return res; } |