aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-17 08:09:51 +0800
committerGitHub <noreply@github.com>2023-01-17 08:09:51 +0800
commitf72cb97fa0db63e14363af60f45d0f2a0a84cc27 (patch)
tree922c64f58ddf328e86df4a1d38d77b8dbe10407b /src/nvim/option.c
parentbbdded5cf7dee5d973f8b659a5748f253755d8d5 (diff)
downloadrneovim-f72cb97fa0db63e14363af60f45d0f2a0a84cc27.tar.gz
rneovim-f72cb97fa0db63e14363af60f45d0f2a0a84cc27.tar.bz2
rneovim-f72cb97fa0db63e14363af60f45d0f2a0a84cc27.zip
vim-patch:9.0.1208: code is indented more than necessary (#21846)
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11819) https://github.com/vim/vim/commit/a41e221935edab62672a15123af48f4f14ac1c7d Cherry-pick check_text_or_curbuf_locked() from patch 9.0.0947. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 02c770e608..85725f36ea 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -674,23 +674,25 @@ void set_helplang_default(const char *lang)
return;
}
int idx = findoption("hlg");
- if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
- if (options[idx].flags & P_ALLOCED) {
- free_string_option(p_hlg);
- }
- p_hlg = xmemdupz(lang, lang_len);
- // zh_CN becomes "cn", zh_TW becomes "tw".
- if (STRNICMP(p_hlg, "zh_", 3) == 0 && strlen(p_hlg) >= 5) {
- p_hlg[0] = (char)TOLOWER_ASC(p_hlg[3]);
- p_hlg[1] = (char)TOLOWER_ASC(p_hlg[4]);
- } else if (strlen(p_hlg) >= 1 && *p_hlg == 'C') {
- // any C like setting, such as C.UTF-8, becomes "en"
- p_hlg[0] = 'e';
- p_hlg[1] = 'n';
- }
- p_hlg[2] = NUL;
- options[idx].flags |= P_ALLOCED;
+ if (idx < 0 || (options[idx].flags & P_WAS_SET)) {
+ return;
+ }
+
+ if (options[idx].flags & P_ALLOCED) {
+ free_string_option(p_hlg);
+ }
+ p_hlg = xmemdupz(lang, lang_len);
+ // zh_CN becomes "cn", zh_TW becomes "tw".
+ if (STRNICMP(p_hlg, "zh_", 3) == 0 && strlen(p_hlg) >= 5) {
+ p_hlg[0] = (char)TOLOWER_ASC(p_hlg[3]);
+ p_hlg[1] = (char)TOLOWER_ASC(p_hlg[4]);
+ } else if (strlen(p_hlg) >= 1 && *p_hlg == 'C') {
+ // any C like setting, such as C.UTF-8, becomes "en"
+ p_hlg[0] = 'e';
+ p_hlg[1] = 'n';
}
+ p_hlg[2] = NUL;
+ options[idx].flags |= P_ALLOCED;
}
/// 'title' and 'icon' only default to true if they have not been set or reset
@@ -5035,10 +5037,11 @@ bool option_was_set(const char *name)
void reset_option_was_set(const char *name)
{
const int idx = findoption(name);
-
- if (idx >= 0) {
- options[idx].flags &= ~P_WAS_SET;
+ if (idx < 0) {
+ return;
}
+
+ options[idx].flags &= ~P_WAS_SET;
}
/// fill_breakat_flags() -- called when 'breakat' changes value.