mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #15941 from dundargoc/refactor/remove-redundant-casts
refactor: remove redundant casts
This commit is contained in:
commit
684299ed4c
@ -418,7 +418,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
|
|||||||
|
|
||||||
try_start();
|
try_start();
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
aucmd_prepbuf(&aco, (buf_T *)buf);
|
aucmd_prepbuf(&aco, buf);
|
||||||
|
|
||||||
if (!MODIFIABLE(buf)) {
|
if (!MODIFIABLE(buf)) {
|
||||||
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
|
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
|
||||||
@ -656,7 +656,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
|
|||||||
|
|
||||||
try_start();
|
try_start();
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
aucmd_prepbuf(&aco, (buf_T *)buf);
|
aucmd_prepbuf(&aco, buf);
|
||||||
|
|
||||||
if (!MODIFIABLE(buf)) {
|
if (!MODIFIABLE(buf)) {
|
||||||
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
|
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
|
||||||
@ -1340,7 +1340,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
|
|||||||
if (extmark.row < 0) {
|
if (extmark.row < 0) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
return extmark_to_array(extmark, false, (bool)details);
|
return extmark_to_array(extmark, false, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets extmarks in "traversal order" from a |charwise| region defined by
|
/// Gets extmarks in "traversal order" from a |charwise| region defined by
|
||||||
@ -1982,7 +1982,7 @@ Object nvim_buf_call(Buffer buffer, LuaRef fun, Error *err)
|
|||||||
}
|
}
|
||||||
try_start();
|
try_start();
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
aucmd_prepbuf(&aco, (buf_T *)buf);
|
aucmd_prepbuf(&aco, buf);
|
||||||
|
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
Object res = nlua_call_ref(fun, NULL, args, true, err);
|
Object res = nlua_call_ref(fun, NULL, args, true, err);
|
||||||
|
@ -625,7 +625,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
|
|||||||
|
|
||||||
// Copy bytes before the cursor.
|
// Copy bytes before the cursor.
|
||||||
if (col > 0) {
|
if (col > 0) {
|
||||||
memmove(newp, oldp, (size_t)col);
|
memmove(newp, oldp, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy bytes after the changed character(s).
|
// Copy bytes after the changed character(s).
|
||||||
|
@ -87,7 +87,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kChannelStreamProc:
|
case kChannelStreamProc:
|
||||||
proc = (Process *)&chan->stream.proc;
|
proc = &chan->stream.proc;
|
||||||
if (part == kChannelPartStdin || close_main) {
|
if (part == kChannelPartStdin || close_main) {
|
||||||
stream_may_close(&proc->in);
|
stream_may_close(&proc->in);
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
|
|||||||
chan->stream.uv = libuv_process_init(&main_loop, chan);
|
chan->stream.uv = libuv_process_init(&main_loop, chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
Process *proc = (Process *)&chan->stream.proc;
|
Process *proc = &chan->stream.proc;
|
||||||
proc->argv = argv;
|
proc->argv = argv;
|
||||||
proc->cb = channel_process_exit_cb;
|
proc->cb = channel_process_exit_cb;
|
||||||
proc->events = chan->events;
|
proc->events = chan->events;
|
||||||
|
@ -3741,7 +3741,7 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
if (cur->conceal_char) {
|
if (cur->conceal_char) {
|
||||||
char buf[MB_MAXBYTES + 1];
|
char buf[MB_MAXBYTES + 1];
|
||||||
|
|
||||||
buf[utf_char2bytes((int)cur->conceal_char, (char_u *)buf)] = NUL;
|
buf[utf_char2bytes(cur->conceal_char, (char_u *)buf)] = NUL;
|
||||||
tv_dict_add_str(dict, S_LEN("conceal"), buf);
|
tv_dict_add_str(dict, S_LEN("conceal"), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5230,7 +5230,7 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Process *proc = (Process *)&data->stream.proc;
|
Process *proc = &data->stream.proc;
|
||||||
rettv->vval.v_number = proc->pid;
|
rettv->vval.v_number = proc->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5528,7 +5528,7 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
// Ignore return code, but show error later.
|
// Ignore return code, but show error later.
|
||||||
(void)channel_close(data->id, kChannelPartRpc, &error);
|
(void)channel_close(data->id, kChannelPartRpc, &error);
|
||||||
}
|
}
|
||||||
process_stop((Process *)&data->stream.proc);
|
process_stop(&data->stream.proc);
|
||||||
rettv->vval.v_number = 1;
|
rettv->vval.v_number = 1;
|
||||||
if (error) {
|
if (error) {
|
||||||
EMSG(error);
|
EMSG(error);
|
||||||
@ -6135,7 +6135,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match = vim_regexec_nl(®match, str, (colnr_T)startcol);
|
match = vim_regexec_nl(®match, str, startcol);
|
||||||
|
|
||||||
if (match && --nth <= 0) {
|
if (match && --nth <= 0) {
|
||||||
break;
|
break;
|
||||||
@ -6346,7 +6346,7 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
: 0));
|
: 0));
|
||||||
|
|
||||||
if (id >= 1 && id <= 3) {
|
if (id >= 1 && id <= 3) {
|
||||||
matchitem_T *const m = (matchitem_T *)get_match(curwin, id);
|
matchitem_T *const m = get_match(curwin, id);
|
||||||
|
|
||||||
if (m != NULL) {
|
if (m != NULL) {
|
||||||
tv_list_append_string(rettv->vval.v_list,
|
tv_list_append_string(rettv->vval.v_list,
|
||||||
@ -6993,7 +6993,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
} else {
|
} else {
|
||||||
tv_list_alloc_ret(rettv, (end - start) / stride);
|
tv_list_alloc_ret(rettv, (end - start) / stride);
|
||||||
for (i = start; stride > 0 ? i <= end : i >= end; i += stride) {
|
for (i = start; stride > 0 ? i <= end : i >= end; i += stride) {
|
||||||
tv_list_append_number(rettv->vval.v_list, (varnumber_T)i);
|
tv_list_append_number(rettv->vval.v_list, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2861,7 +2861,7 @@ bool tv_equal(typval_T *const tv1, typval_T *const tv2, const bool ic, const boo
|
|||||||
char buf2[NUMBUFLEN];
|
char buf2[NUMBUFLEN];
|
||||||
const char *s1 = tv_get_string_buf(tv1, buf1);
|
const char *s1 = tv_get_string_buf(tv1, buf1);
|
||||||
const char *s2 = tv_get_string_buf(tv2, buf2);
|
const char *s2 = tv_get_string_buf(tv2, buf2);
|
||||||
return mb_strcmp_ic((bool)ic, s1, s2) == 0;
|
return mb_strcmp_ic(ic, s1, s2) == 0;
|
||||||
}
|
}
|
||||||
case VAR_BOOL:
|
case VAR_BOOL:
|
||||||
return tv1->vval.v_bool == tv2->vval.v_bool;
|
return tv1->vval.v_bool == tv2->vval.v_bool;
|
||||||
|
@ -723,7 +723,7 @@ void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t
|
|||||||
uint64_t src2ns(Integer *src_id)
|
uint64_t src2ns(Integer *src_id)
|
||||||
{
|
{
|
||||||
if (*src_id == 0) {
|
if (*src_id == 0) {
|
||||||
*src_id = (Integer)nvim_create_namespace((String)STRING_INIT);
|
*src_id = nvim_create_namespace((String)STRING_INIT);
|
||||||
}
|
}
|
||||||
if (*src_id < 0) {
|
if (*src_id < 0) {
|
||||||
return UINT64_MAX;
|
return UINT64_MAX;
|
||||||
|
@ -1294,7 +1294,7 @@ static int cs_kill(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs_kill_execute((size_t)i, stok);
|
cs_kill_execute(i, stok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1559,8 +1559,8 @@ static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a,
|
|||||||
assert(totmatches > 0);
|
assert(totmatches > 0);
|
||||||
|
|
||||||
buf = xmalloc(CSREAD_BUFSIZE);
|
buf = xmalloc(CSREAD_BUFSIZE);
|
||||||
matches = xmalloc(sizeof(char *) * (size_t)totmatches);
|
matches = xmalloc(sizeof(char *) * totmatches);
|
||||||
cntxts = xmalloc(sizeof(char *) * (size_t)totmatches);
|
cntxts = xmalloc(sizeof(char *) * totmatches);
|
||||||
|
|
||||||
for (size_t i = 0; i < csinfo_size; i++) {
|
for (size_t i = 0; i < csinfo_size; i++) {
|
||||||
if (nummatches_a[i] < 1) {
|
if (nummatches_a[i] < 1) {
|
||||||
|
@ -837,8 +837,8 @@ bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_
|
|||||||
int old_extent_col, int new_extent_line, int new_extent_col)
|
int old_extent_col, int new_extent_line, int new_extent_col)
|
||||||
{
|
{
|
||||||
mtpos_t start = { start_line, start_col };
|
mtpos_t start = { start_line, start_col };
|
||||||
mtpos_t old_extent = { (int)old_extent_line, old_extent_col };
|
mtpos_t old_extent = { old_extent_line, old_extent_col };
|
||||||
mtpos_t new_extent = { (int)new_extent_line, new_extent_col };
|
mtpos_t new_extent = { new_extent_line, new_extent_col };
|
||||||
|
|
||||||
bool may_delete = (old_extent.row != 0 || old_extent.col != 0);
|
bool may_delete = (old_extent.row != 0 || old_extent.col != 0);
|
||||||
bool same_line = old_extent.row == 0 && new_extent.row == 0;
|
bool same_line = old_extent.row == 0 && new_extent.row == 0;
|
||||||
|
@ -857,7 +857,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
|||||||
MSG_PUTS(" ");
|
MSG_PUTS(" ");
|
||||||
}
|
}
|
||||||
if (menu->priority) {
|
if (menu->priority) {
|
||||||
msg_outnum((long)menu->priority);
|
msg_outnum(menu->priority);
|
||||||
MSG_PUTS(" ");
|
MSG_PUTS(" ");
|
||||||
}
|
}
|
||||||
// Same highlighting as for directories!?
|
// Same highlighting as for directories!?
|
||||||
|
@ -2363,7 +2363,7 @@ void msg_reset_scroll(void)
|
|||||||
// non-displayed part of msg_grid is considered invalid.
|
// non-displayed part of msg_grid is considered invalid.
|
||||||
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.Rows); i++) {
|
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.Rows); i++) {
|
||||||
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
|
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
|
||||||
(int)msg_grid.Columns, false);
|
msg_grid.Columns, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3899,7 +3899,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
|||||||
// when 'buflisted' changes, trigger autocommands
|
// when 'buflisted' changes, trigger autocommands
|
||||||
apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
|
apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
|
||||||
NULL, NULL, true, curbuf);
|
NULL, NULL, true, curbuf);
|
||||||
} else if ((int *)varp == (int *)&curbuf->b_p_swf) {
|
} else if ((int *)varp == &curbuf->b_p_swf) {
|
||||||
// when 'swf' is set, create swapfile, when reset remove swapfile
|
// when 'swf' is set, create swapfile, when reset remove swapfile
|
||||||
if (curbuf->b_p_swf && p_uc) {
|
if (curbuf->b_p_swf && p_uc) {
|
||||||
ml_open_file(curbuf); // create the swap file
|
ml_open_file(curbuf); // create the swap file
|
||||||
|
@ -2401,7 +2401,7 @@ static inline void shada_initialize_registers(WriteMergerState *const wms, int m
|
|||||||
.data = {
|
.data = {
|
||||||
.reg = {
|
.reg = {
|
||||||
.contents = (char **)reg.y_array,
|
.contents = (char **)reg.y_array,
|
||||||
.contents_size = (size_t)reg.y_size,
|
.contents_size = reg.y_size,
|
||||||
.type = reg.y_type,
|
.type = reg.y_type,
|
||||||
.width = (size_t)(reg.y_type == kMTBlockWise ? reg.y_width : 0),
|
.width = (size_t)(reg.y_type == kMTBlockWise ? reg.y_width : 0),
|
||||||
.additional_data = reg.additional_data,
|
.additional_data = reg.additional_data,
|
||||||
|
@ -2924,8 +2924,8 @@ void spell_suggest(int count)
|
|||||||
|
|
||||||
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
|
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
|
||||||
// 'spellsuggest', whatever is smaller.
|
// 'spellsuggest', whatever is smaller.
|
||||||
if (sps_limit > (int)Rows - 2) {
|
if (sps_limit > Rows - 2) {
|
||||||
limit = (int)Rows - 2;
|
limit = Rows - 2;
|
||||||
} else {
|
} else {
|
||||||
limit = sps_limit;
|
limit = sps_limit;
|
||||||
}
|
}
|
||||||
|
@ -1241,7 +1241,7 @@ static bool send_mouse_event(Terminal *term, int c)
|
|||||||
mouse_action(term, button, row, col - offset, drag, 0);
|
mouse_action(term, button, row, col - offset, drag, 0);
|
||||||
size_t len = vterm_output_read(term->vt, term->textbuf,
|
size_t len = vterm_output_read(term->vt, term->textbuf,
|
||||||
sizeof(term->textbuf));
|
sizeof(term->textbuf));
|
||||||
terminal_send(term, term->textbuf, (size_t)len);
|
terminal_send(term, term->textbuf, len);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user