mirror of
https://github.com/vim/vim.git
synced 2025-11-14 23:04:02 -05:00
patch 9.0.1237: 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 #11858)
This commit is contained in:
committed by
Bram Moolenaar
parent
9cbf791995
commit
6ec6666047
@@ -282,24 +282,23 @@ score_wordcount_adj(
|
||||
int newscore;
|
||||
|
||||
hi = hash_find(&slang->sl_wordcount, word);
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
{
|
||||
wc = HI2WC(hi);
|
||||
if (wc->wc_count < SCORE_THRES2)
|
||||
bonus = SCORE_COMMON1;
|
||||
else if (wc->wc_count < SCORE_THRES3)
|
||||
bonus = SCORE_COMMON2;
|
||||
else
|
||||
bonus = SCORE_COMMON3;
|
||||
if (split)
|
||||
newscore = score - bonus / 2;
|
||||
else
|
||||
newscore = score - bonus;
|
||||
if (newscore < 0)
|
||||
return 0;
|
||||
return newscore;
|
||||
}
|
||||
return score;
|
||||
if (HASHITEM_EMPTY(hi))
|
||||
return score;
|
||||
|
||||
wc = HI2WC(hi);
|
||||
if (wc->wc_count < SCORE_THRES2)
|
||||
bonus = SCORE_COMMON1;
|
||||
else if (wc->wc_count < SCORE_THRES3)
|
||||
bonus = SCORE_COMMON2;
|
||||
else
|
||||
bonus = SCORE_COMMON3;
|
||||
if (split)
|
||||
newscore = score - bonus / 2;
|
||||
else
|
||||
newscore = score - bonus;
|
||||
if (newscore < 0)
|
||||
return 0;
|
||||
return newscore;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -316,36 +315,37 @@ badword_captype(char_u *word, char_u *end)
|
||||
int first;
|
||||
char_u *p;
|
||||
|
||||
if (flags & WF_KEEPCAP)
|
||||
if (!(flags & WF_KEEPCAP))
|
||||
return flags;
|
||||
|
||||
// Count the number of UPPER and lower case letters.
|
||||
l = u = 0;
|
||||
first = FALSE;
|
||||
for (p = word; p < end; MB_PTR_ADV(p))
|
||||
{
|
||||
// Count the number of UPPER and lower case letters.
|
||||
l = u = 0;
|
||||
first = FALSE;
|
||||
for (p = word; p < end; MB_PTR_ADV(p))
|
||||
c = PTR2CHAR(p);
|
||||
if (SPELL_ISUPPER(c))
|
||||
{
|
||||
c = PTR2CHAR(p);
|
||||
if (SPELL_ISUPPER(c))
|
||||
{
|
||||
++u;
|
||||
if (p == word)
|
||||
first = TRUE;
|
||||
}
|
||||
else
|
||||
++l;
|
||||
++u;
|
||||
if (p == word)
|
||||
first = TRUE;
|
||||
}
|
||||
|
||||
// If there are more UPPER than lower case letters suggest an
|
||||
// ALLCAP word. Otherwise, if the first letter is UPPER then
|
||||
// suggest ONECAP. Exception: "ALl" most likely should be "All",
|
||||
// require three upper case letters.
|
||||
if (u > l && u > 2)
|
||||
flags |= WF_ALLCAP;
|
||||
else if (first)
|
||||
flags |= WF_ONECAP;
|
||||
|
||||
if (u >= 2 && l >= 2) // maCARONI maCAroni
|
||||
flags |= WF_MIXCAP;
|
||||
else
|
||||
++l;
|
||||
}
|
||||
|
||||
// If there are more UPPER than lower case letters suggest an
|
||||
// ALLCAP word. Otherwise, if the first letter is UPPER then
|
||||
// suggest ONECAP. Exception: "ALl" most likely should be "All",
|
||||
// require three upper case letters.
|
||||
if (u > l && u > 2)
|
||||
flags |= WF_ALLCAP;
|
||||
else if (first)
|
||||
flags |= WF_ONECAP;
|
||||
|
||||
if (u >= 2 && l >= 2) // maCARONI maCAroni
|
||||
flags |= WF_MIXCAP;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -3692,12 +3692,11 @@ add_banned(
|
||||
|
||||
hash = hash_hash(word);
|
||||
hi = hash_lookup(&su->su_banned, word, hash);
|
||||
if (HASHITEM_EMPTY(hi))
|
||||
{
|
||||
s = vim_strsave(word);
|
||||
if (s != NULL)
|
||||
hash_add_item(&su->su_banned, hi, s, hash);
|
||||
}
|
||||
if (!HASHITEM_EMPTY(hi)) // already present
|
||||
return;
|
||||
s = vim_strsave(word);
|
||||
if (s != NULL)
|
||||
hash_add_item(&su->su_banned, hi, s, hash);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3778,25 +3777,25 @@ cleanup_suggestions(
|
||||
int maxscore,
|
||||
int keep) // nr of suggestions to keep
|
||||
{
|
||||
if (gap->ga_len > 0)
|
||||
if (gap->ga_len <= 0)
|
||||
return maxscore;
|
||||
|
||||
// Sort the list.
|
||||
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T),
|
||||
sug_compare);
|
||||
|
||||
// Truncate the list to the number of suggestions that will be
|
||||
// displayed.
|
||||
if (gap->ga_len > keep)
|
||||
{
|
||||
// Sort the list.
|
||||
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T),
|
||||
sug_compare);
|
||||
int i;
|
||||
suggest_T *stp = &SUG(*gap, 0);
|
||||
|
||||
// Truncate the list to the number of suggestions that will be
|
||||
// displayed.
|
||||
if (gap->ga_len > keep)
|
||||
{
|
||||
int i;
|
||||
suggest_T *stp = &SUG(*gap, 0);
|
||||
|
||||
for (i = keep; i < gap->ga_len; ++i)
|
||||
vim_free(stp[i].st_word);
|
||||
gap->ga_len = keep;
|
||||
if (keep >= 1)
|
||||
return stp[keep - 1].st_score;
|
||||
}
|
||||
for (i = keep; i < gap->ga_len; ++i)
|
||||
vim_free(stp[i].st_word);
|
||||
gap->ga_len = keep;
|
||||
if (keep >= 1)
|
||||
return stp[keep - 1].st_score;
|
||||
}
|
||||
return maxscore;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user