aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval
diff options
context:
space:
mode:
authorii14 <59243201+ii14@users.noreply.github.com>2023-04-07 21:08:16 +0200
committerGitHub <noreply@github.com>2023-04-07 21:08:16 +0200
commit04933b1ea968f958d2541dd65fd33ebb503caac3 (patch)
tree430e333892c440dccce4d1b4606c83ab36f817c5 /src/nvim/eval
parent9408f2dcf7cade2631688300e9b58eed6bc5219a (diff)
downloadrneovim-04933b1ea968f958d2541dd65fd33ebb503caac3.tar.gz
rneovim-04933b1ea968f958d2541dd65fd33ebb503caac3.tar.bz2
rneovim-04933b1ea968f958d2541dd65fd33ebb503caac3.zip
refactor: remove redundant casts
Diffstat (limited to 'src/nvim/eval')
-rw-r--r--src/nvim/eval/funcs.c8
-rw-r--r--src/nvim/eval/typval.c2
-rw-r--r--src/nvim/eval/userfunc.c6
-rw-r--r--src/nvim/eval/vars.c24
4 files changed, 19 insertions, 21 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index b7425b1ef3..eaa66f6483 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -9093,14 +9093,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (dir == 0 || dir == 1) {
// Trim leading characters
while (*head != NUL) {
- c1 = utf_ptr2char((char *)head);
+ c1 = utf_ptr2char(head);
if (mask == NULL) {
if (c1 > ' ' && c1 != 0xa0) {
break;
}
} else {
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
- if (c1 == utf_ptr2char((char *)p)) {
+ if (c1 == utf_ptr2char(p)) {
break;
}
}
@@ -9118,14 +9118,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
for (; tail > head; tail = prev) {
prev = tail;
MB_PTR_BACK(head, prev);
- c1 = utf_ptr2char((char *)prev);
+ c1 = utf_ptr2char(prev);
if (mask == NULL) {
if (c1 > ' ' && c1 != 0xa0) {
break;
}
} else {
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
- if (c1 == utf_ptr2char((char *)p)) {
+ if (c1 == utf_ptr2char(p)) {
break;
}
}
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index e027517108..bfac1ca864 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -898,7 +898,7 @@ void f_list2str(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
TV_LIST_ITER_CONST(l, li, {
buf[utf_char2bytes((int)tv_get_number(TV_LIST_ITEM_TV(li)), (char *)buf)] = NUL;
- ga_concat(&ga, (char *)buf);
+ ga_concat(&ga, buf);
});
ga_append(&ga, NUL);
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 99e8859ae9..9c1e8230a3 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -611,7 +611,7 @@ static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr)
STRCPY(v->di_key, name);
#endif
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
- hash_add(&dp->dv_hashtab, (char *)v->di_key);
+ hash_add(&dp->dv_hashtab, v->di_key);
v->di_tv.v_type = VAR_NUMBER;
v->di_tv.v_lock = VAR_FIXED;
v->di_tv.vval.v_number = nr;
@@ -2612,7 +2612,7 @@ void ex_function(exarg_T *eap)
set_ufunc_name(fp, name);
if (overwrite) {
hi = hash_find(&func_hashtab, name);
- hi->hi_key = (char *)UF2HIKEY(fp);
+ hi->hi_key = UF2HIKEY(fp);
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
xfree(fp);
goto erret;
@@ -2681,7 +2681,7 @@ int eval_fname_script(const char *const p)
bool translated_function_exists(const char *name)
{
if (builtin_function(name, -1)) {
- return find_internal_func((char *)name) != NULL;
+ return find_internal_func(name) != NULL;
}
return find_func(name) != NULL;
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index e0f7af5718..77b40fbf11 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -197,10 +197,10 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
int var_count = 0;
int semicolon = 0;
char op[2];
- char *argend;
+ const char *argend;
int first = true;
- argend = (char *)skip_var_list(arg, &var_count, &semicolon);
+ argend = skip_var_list(arg, &var_count, &semicolon);
if (argend == NULL) {
return;
}
@@ -235,8 +235,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
if (!eap->skip) {
op[0] = '=';
op[1] = NUL;
- (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
- is_const, (char *)op);
+ (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
}
tv_clear(&rettv);
}
@@ -267,8 +266,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
}
emsg_skip--;
} else if (i != FAIL) {
- (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count,
- is_const, (char *)op);
+ (void)ex_let_vars(eap->arg, &rettv, false, semicolon, var_count, is_const, op);
tv_clear(&rettv);
}
}
@@ -375,7 +373,7 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
const char *p = arg;
for (;;) {
p = skipwhite(p + 1); // skip whites after '[', ';' or ','
- s = skip_var_one((char *)p);
+ s = skip_var_one(p);
if (s == p) {
semsg(_(e_invarg2), p);
return NULL;
@@ -398,7 +396,7 @@ const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
}
return p + 1;
}
- return skip_var_one((char *)arg);
+ return skip_var_one(arg);
}
/// Skip one (assignable) variable name, including @r, $VAR, &option, d.key,
@@ -430,7 +428,7 @@ void list_hashtable_vars(hashtab_T *ht, const char *prefix, int empty, int *firs
// apply :filter /pat/ to variable name
xstrlcpy(buf, prefix, IOSIZE);
- xstrlcat(buf, (char *)di->di_key, IOSIZE);
+ xstrlcat(buf, di->di_key, IOSIZE);
if (message_filtered(buf)) {
continue;
}
@@ -915,7 +913,7 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
if (watched) {
tv_copy(&di->di_tv, &oldtv);
// need to save key because dictitem_remove will free it
- key = xstrdup((char *)di->di_key);
+ key = xstrdup(di->di_key);
}
tv_dict_item_remove(d, di);
@@ -1169,7 +1167,7 @@ void delete_var(hashtab_T *ht, hashitem_T *hi)
static void list_one_var(dictitem_T *v, const char *prefix, int *first)
{
char *const s = encode_tv2echo(&v->di_tv, NULL);
- list_one_var_a(prefix, v->di_key, (ptrdiff_t)strlen((char *)v->di_key),
+ list_one_var_a(prefix, v->di_key, (ptrdiff_t)strlen(v->di_key),
v->di_tv.v_type, (s == NULL ? "" : s), first);
xfree(s);
}
@@ -1343,7 +1341,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv,
v = xmalloc(offsetof(dictitem_T, di_key) + strlen(varname) + 1);
STRCPY(v->di_key, varname);
- if (hash_add(ht, (char *)v->di_key) == FAIL) {
+ if (hash_add(ht, v->di_key) == FAIL) {
xfree(v);
return;
}
@@ -1362,7 +1360,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv,
}
if (watched) {
- tv_dict_watcher_notify(dict, (char *)v->di_key, &v->di_tv, &oldtv);
+ tv_dict_watcher_notify(dict, v->di_key, &v->di_tv, &oldtv);
tv_clear(&oldtv);
}