aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-11-13 23:40:37 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-11-19 15:08:35 +0100
commitac1113ded5f8f09dd99a9894d7a7e795626fb728 (patch)
tree9cf615d03efafe2c44e539cb45f1b3df171b3e85 /src/nvim/eval/typval.c
parent1798a4b5e9f0ae56cd800095f79423fea5cae8ca (diff)
downloadrneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.gz
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.tar.bz2
rneovim-ac1113ded5f8f09dd99a9894d7a7e795626fb728.zip
refactor: follow style guide
- reduce variable scope - prefer initialization over declaration and assignment
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 8a38315706..74bde0147d 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1155,9 +1155,8 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
res = sortinfo->item_compare_ic ? STRICMP(p1, p2) : strcmp(p1, p2);
}
} else {
- double n1, n2;
- n1 = strtod(p1, &p1);
- n2 = strtod(p2, &p2);
+ double n1 = strtod(p1, &p1);
+ double n2 = strtod(p2, &p2);
res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
}
@@ -1187,8 +1186,6 @@ static int item_compare_not_keeping_zero(const void *s1, const void *s2)
static int item_compare2(const void *s1, const void *s2, bool keep_zero)
{
- ListSortItem *si1, *si2;
- int res;
typval_T rettv;
typval_T argv[3];
const char *func_name;
@@ -1199,8 +1196,8 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero)
return 0;
}
- si1 = (ListSortItem *)s1;
- si2 = (ListSortItem *)s2;
+ ListSortItem *si1 = (ListSortItem *)s1;
+ ListSortItem *si2 = (ListSortItem *)s2;
if (partial == NULL) {
func_name = sortinfo->item_compare_func;
@@ -1218,7 +1215,7 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero)
funcexe.fe_evaluate = true;
funcexe.fe_partial = partial;
funcexe.fe_selfdict = sortinfo->item_compare_selfdict;
- res = call_func(func_name, -1, &rettv, 2, argv, &funcexe);
+ int res = call_func(func_name, -1, &rettv, 2, argv, &funcexe);
tv_clear(&argv[0]);
tv_clear(&argv[1]);