mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
vim-patch:9.0.1245: code is indented more than necessary (#21998)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11879)
032713f829
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -7823,7 +7823,9 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
// MSVC returns NULL for an invalid value of seconds.
|
||||
if (curtime_ptr == NULL) {
|
||||
rettv->vval.v_string = xstrdup(_("(Invalid)"));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
vimconv_T conv;
|
||||
|
||||
conv.vc_type = CONV_NONE;
|
||||
@@ -7851,7 +7853,6 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
convert_setup(&conv, NULL, NULL);
|
||||
xfree(enc);
|
||||
}
|
||||
}
|
||||
|
||||
/// "strgetchar()" function
|
||||
static void f_strgetchar(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
@@ -8654,6 +8655,7 @@ static void f_timer_pause(typval_T *argvars, typval_T *unused, EvalFuncData fptr
|
||||
emsg(_(e_number_exp));
|
||||
return;
|
||||
}
|
||||
|
||||
int paused = (bool)tv_get_number(&argvars[1]);
|
||||
timer_T *timer = find_timer_by_nr(tv_get_number(&argvars[0]));
|
||||
if (timer != NULL) {
|
||||
|
@@ -3208,7 +3208,10 @@ static inline void _nothing_conv_dict_end(typval_T *const tv, dict_T **const dic
|
||||
/// @param[in,out] tv Value to free.
|
||||
void tv_clear(typval_T *const tv)
|
||||
{
|
||||
if (tv != NULL && tv->v_type != VAR_UNKNOWN) {
|
||||
if (tv == NULL || tv->v_type == VAR_UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
// WARNING: do not translate the string here, gettext is slow and function
|
||||
// is used *very* often. At the current state encode_vim_to_nothing() does
|
||||
// not error out and does not use the argument anywhere.
|
||||
@@ -3219,7 +3222,6 @@ void tv_clear(typval_T *const tv)
|
||||
(void)evn_ret;
|
||||
assert(evn_ret == OK);
|
||||
}
|
||||
}
|
||||
|
||||
//{{{3 Free
|
||||
|
||||
@@ -3228,7 +3230,10 @@ void tv_clear(typval_T *const tv)
|
||||
/// @param tv Object to free.
|
||||
void tv_free(typval_T *tv)
|
||||
{
|
||||
if (tv != NULL) {
|
||||
if (tv == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tv->v_type) {
|
||||
case VAR_PARTIAL:
|
||||
partial_unref(tv->vval.v_partial);
|
||||
@@ -3257,7 +3262,6 @@ void tv_free(typval_T *tv)
|
||||
}
|
||||
xfree(tv);
|
||||
}
|
||||
}
|
||||
|
||||
//{{{3 Copy
|
||||
|
||||
|
@@ -2732,7 +2732,10 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
||||
tagp->tagline = 0;
|
||||
tagp->command_end = NULL;
|
||||
|
||||
if (retval == OK) {
|
||||
if (retval != OK) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Try to find a kind field: "kind:<kind>" or just "<kind>"
|
||||
p = tagp->command;
|
||||
if (find_extra(&p) == OK) {
|
||||
@@ -2781,7 +2784,6 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
||||
MB_PTR_ADV(p)) {}
|
||||
tagp->user_data_end = p;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -3329,7 +3331,10 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
||||
|
||||
ret = find_tags(pat, &num_matches, &matches,
|
||||
TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname);
|
||||
if (ret == OK && num_matches > 0) {
|
||||
if (ret != OK || num_matches <= 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_matches; i++) {
|
||||
int parse_result = parse_match(matches[i], &tp);
|
||||
|
||||
@@ -3408,7 +3413,6 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
||||
xfree(matches[i]);
|
||||
}
|
||||
xfree(matches);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,9 @@ static void ga_concat_esc(garray_T *gap, const char *p, int clen)
|
||||
memmove(buf, p, (size_t)clen);
|
||||
buf[clen] = NUL;
|
||||
ga_concat(gap, buf);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (*p) {
|
||||
case BS:
|
||||
ga_concat(gap, "\\b"); break;
|
||||
@@ -103,7 +105,6 @@ static void ga_concat_esc(garray_T *gap, const char *p, int clen)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Append "str" to "gap", escaping unprintable characters.
|
||||
/// Changes NL to \n, CR to \r, etc.
|
||||
|
@@ -736,7 +736,10 @@ void check_auto_format(bool end_insert)
|
||||
int c = ' ';
|
||||
int cc;
|
||||
|
||||
if (did_add_space) {
|
||||
if (!did_add_space) {
|
||||
return;
|
||||
}
|
||||
|
||||
cc = gchar_cursor();
|
||||
if (!WHITECHAR(cc)) {
|
||||
// Somehow the space was removed already.
|
||||
@@ -754,7 +757,6 @@ void check_auto_format(bool end_insert)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Find out textwidth to be used for formatting:
|
||||
/// if 'textwidth' option is set, use it
|
||||
|
Reference in New Issue
Block a user