Skip to content

Commit

Permalink
patch 9.0.1237: code is indented more than necessary
Browse files Browse the repository at this point in the history
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11858)
  • Loading branch information
yegappan authored and brammool committed Jan 23, 2023
1 parent 9cbf791 commit 6ec6666
Show file tree
Hide file tree
Showing 12 changed files with 1,080 additions and 1,081 deletions.
793 changes: 395 additions & 398 deletions src/screen.c

Large diffs are not rendered by default.

81 changes: 39 additions & 42 deletions src/scriptfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ estack_push(etype_T type, char_u *name, long lnum)

// If memory allocation fails then we'll pop more than we push, eventually
// at the top level it will be OK again.
if (ga_grow(&exestack, 1) == OK)
{
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
entry->es_type = type;
entry->es_name = name;
entry->es_lnum = lnum;
if (ga_grow(&exestack, 1) != OK)
return NULL;

entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
entry->es_type = type;
entry->es_name = name;
entry->es_lnum = lnum;
#ifdef FEAT_EVAL
entry->es_info.ufunc = NULL;
entry->es_info.ufunc = NULL;
#endif
++exestack.ga_len;
return entry;
}
return NULL;
++exestack.ga_len;
return entry;
}

#if defined(FEAT_EVAL) || defined(PROTO)
Expand Down Expand Up @@ -667,12 +666,12 @@ source_all_matches(char_u *pat)
char_u **files;
int i;

if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK)
{
for (i = 0; i < num_files; ++i)
(void)do_source(files[i], FALSE, DOSO_NONE, NULL);
FreeWild(num_files, files);
}
if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) != OK)
return;

for (i = 0; i < num_files; ++i)
(void)do_source(files[i], FALSE, DOSO_NONE, NULL);
FreeWild(num_files, files);
}

/*
Expand Down Expand Up @@ -2616,36 +2615,34 @@ get_autoload_prefix(scriptitem_T *si)
char_u *
may_prefix_autoload(char_u *name)
{
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
return name;

if (si->sn_autoload_prefix != NULL)
{
char_u *basename = name;
size_t len;
char_u *res;
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);

if (*name == K_SPECIAL)
{
char_u *p = vim_strchr(name, '_');
if (si->sn_autoload_prefix == NULL)
return name;

// skip over "<SNR>99_"
if (p != NULL)
basename = p + 1;
}
char_u *basename = name;
size_t len;
char_u *res;

len = STRLEN(si->sn_autoload_prefix) + STRLEN(basename) + 2;
res = alloc(len);
if (res != NULL)
{
vim_snprintf((char *)res, len, "%s%s",
si->sn_autoload_prefix, basename);
return res;
}
}
if (*name == K_SPECIAL)
{
char_u *p = vim_strchr(name, '_');

// skip over "<SNR>99_"
if (p != NULL)
basename = p + 1;
}
return name;

len = STRLEN(si->sn_autoload_prefix) + STRLEN(basename) + 2;
res = alloc(len);
if (res == NULL)
return NULL;

vim_snprintf((char *)res, len, "%s%s", si->sn_autoload_prefix, basename);
return res;
}

/*
Expand Down

0 comments on commit 6ec6666

Please sign in to comment.