mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
refactor(clang-tidy): remove redundant casts
This commit is contained in:
parent
6674d706d9
commit
a1b045f60a
@ -404,7 +404,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
|
||||
// If the size of the range is reducing (ie, new_len < old_len) we
|
||||
// need to delete some old_len. We do this at the start, by
|
||||
// repeatedly deleting line "start".
|
||||
size_t to_delete = (new_len < old_len) ? (size_t)(old_len - new_len) : 0;
|
||||
size_t to_delete = (new_len < old_len) ? old_len - new_len : 0;
|
||||
for (size_t i = 0; i < to_delete; i++) {
|
||||
if (ml_delete((linenr_T)start, false) == FAIL) {
|
||||
api_set_error(err, kErrorTypeException, "Failed to delete line");
|
||||
@ -648,7 +648,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
|
||||
// If the size of the range is reducing (ie, new_len < old_len) we
|
||||
// need to delete some old_len. We do this at the start, by
|
||||
// repeatedly deleting line "start".
|
||||
size_t to_delete = (new_len < old_len) ? (size_t)(old_len - new_len) : 0;
|
||||
size_t to_delete = (new_len < old_len) ? old_len - new_len : 0;
|
||||
for (size_t i = 0; i < to_delete; i++) {
|
||||
if (ml_delete((linenr_T)start_row, false) == FAIL) {
|
||||
api_set_error(err, kErrorTypeException, "Failed to delete line");
|
||||
|
@ -711,8 +711,7 @@ void ins_char_bytes(char *buf, size_t charlen)
|
||||
// Copy bytes after the changed character(s).
|
||||
char *p = newp + col;
|
||||
if (linelen > col + oldlen) {
|
||||
memmove(p + newlen, oldp + col + oldlen,
|
||||
(size_t)(linelen - col - oldlen));
|
||||
memmove(p + newlen, oldp + col + oldlen, linelen - col - oldlen);
|
||||
}
|
||||
|
||||
// Insert or overwrite the new character.
|
||||
|
@ -4037,7 +4037,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions
|
||||
// Don't move anything, just compute the final line length
|
||||
// and setup the array of space strings lengths
|
||||
for (t = 0; t < (linenr_T)count; t++) {
|
||||
curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
|
||||
curr_start = ml_get(curwin->w_cursor.lnum + t);
|
||||
curr = curr_start;
|
||||
if (t == 0 && setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||
// Set the '[ mark.
|
||||
@ -5555,7 +5555,7 @@ void cursor_pos_info(dict_T *dict)
|
||||
// Don't shorten this message, the user asked for it.
|
||||
tv_dict_add_nr(dict, S_LEN("words"), word_count);
|
||||
tv_dict_add_nr(dict, S_LEN("chars"), char_count);
|
||||
tv_dict_add_nr(dict, S_LEN("bytes"), (varnumber_T)(byte_count + bom_count));
|
||||
tv_dict_add_nr(dict, S_LEN("bytes"), byte_count + bom_count);
|
||||
|
||||
STATIC_ASSERT(sizeof("visual") == sizeof("cursor"),
|
||||
"key_len argument in tv_dict_add_nr is wrong");
|
||||
|
@ -1641,21 +1641,21 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
break;
|
||||
}
|
||||
case kSDItemSearchPattern: {
|
||||
const size_t map_size = (size_t)(
|
||||
1 // Search pattern is always present
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.magic)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.is_last_used)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.smartcase)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.has_line_offset)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.place_cursor_at_end)
|
||||
+ ONE_IF_NOT_DEFAULT(entry,
|
||||
search_pattern.is_substitute_pattern)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.highlighted)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.offset)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.search_backward)
|
||||
// finally, additional data:
|
||||
+ (size_t)(
|
||||
entry.data.search_pattern.additional_data
|
||||
const size_t map_size = (
|
||||
1 // Search pattern is always present
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.magic)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.is_last_used)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.smartcase)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.has_line_offset)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.place_cursor_at_end)
|
||||
+ ONE_IF_NOT_DEFAULT(entry,
|
||||
search_pattern.is_substitute_pattern)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.highlighted)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.offset)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.search_backward)
|
||||
// finally, additional data:
|
||||
+ (
|
||||
entry.data.search_pattern.additional_data
|
||||
? entry.data.search_pattern.additional_data->dv_hashtab.ht_used
|
||||
: 0));
|
||||
msgpack_pack_map(spacker, map_size);
|
||||
@ -1682,14 +1682,14 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
case kSDItemGlobalMark:
|
||||
case kSDItemLocalMark:
|
||||
case kSDItemJump: {
|
||||
const size_t map_size = (size_t)(
|
||||
1 // File name
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.mark.lnum)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.mark.col)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.name)
|
||||
// Additional entries, if any:
|
||||
+ (size_t)(
|
||||
entry.data.filemark.additional_data == NULL
|
||||
const size_t map_size = (
|
||||
1 // File name
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.mark.lnum)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.mark.col)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, filemark.name)
|
||||
// Additional entries, if any:
|
||||
+ (
|
||||
entry.data.filemark.additional_data == NULL
|
||||
? 0
|
||||
: entry.data.filemark.additional_data->dv_hashtab.ht_used));
|
||||
msgpack_pack_map(spacker, map_size);
|
||||
@ -1715,14 +1715,14 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
break;
|
||||
}
|
||||
case kSDItemRegister: {
|
||||
const size_t map_size = (size_t)(2 // Register contents and name
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.type)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.width)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.is_unnamed)
|
||||
// Additional entries, if any:
|
||||
+ (size_t)(entry.data.reg.additional_data == NULL
|
||||
? 0
|
||||
: entry.data.reg.additional_data->dv_hashtab.ht_used));
|
||||
const size_t map_size = (2 // Register contents and name
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.type)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.width)
|
||||
+ ONE_IF_NOT_DEFAULT(entry, reg.is_unnamed)
|
||||
// Additional entries, if any:
|
||||
+ (entry.data.reg.additional_data == NULL
|
||||
? 0
|
||||
: entry.data.reg.additional_data->dv_hashtab.ht_used));
|
||||
msgpack_pack_map(spacker, map_size);
|
||||
PACK_STATIC_STR(REG_KEY_CONTENTS);
|
||||
msgpack_pack_array(spacker, entry.data.reg.contents_size);
|
||||
@ -1753,16 +1753,16 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
||||
case kSDItemBufferList:
|
||||
msgpack_pack_array(spacker, entry.data.buffer_list.size);
|
||||
for (size_t i = 0; i < entry.data.buffer_list.size; i++) {
|
||||
const size_t map_size = (size_t)(
|
||||
1 // Buffer name
|
||||
+ (size_t)(entry.data.buffer_list.buffers[i].pos.lnum
|
||||
!= default_pos.lnum)
|
||||
+ (size_t)(entry.data.buffer_list.buffers[i].pos.col
|
||||
!= default_pos.col)
|
||||
// Additional entries, if any:
|
||||
+ (size_t)(
|
||||
entry.data.buffer_list.buffers[i].additional_data
|
||||
== NULL
|
||||
const size_t map_size = (
|
||||
1 // Buffer name
|
||||
+ (size_t)(entry.data.buffer_list.buffers[i].pos.lnum
|
||||
!= default_pos.lnum)
|
||||
+ (size_t)(entry.data.buffer_list.buffers[i].pos.col
|
||||
!= default_pos.col)
|
||||
// Additional entries, if any:
|
||||
+ (
|
||||
entry.data.buffer_list.buffers[i].additional_data
|
||||
== NULL
|
||||
? 0
|
||||
: (entry.data.buffer_list.buffers[i].additional_data
|
||||
->dv_hashtab.ht_used)));
|
||||
|
@ -367,7 +367,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
||||
// uses recorded position to scale number down when processing exponent.
|
||||
float_T significand_part = 0;
|
||||
uvarnumber_T exp_part = 0;
|
||||
const size_t frac_size = (size_t)(frac_end - frac_start);
|
||||
const size_t frac_size = frac_end - frac_start;
|
||||
for (size_t i = 0; i < frac_end; i++) {
|
||||
if (i == frac_start - 1) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user