aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
authorkylo252 <59826753+kylo252@users.noreply.github.com>2021-10-06 18:21:41 +0200
committerkylo252 <59826753+kylo252@users.noreply.github.com>2021-10-06 18:21:43 +0200
commit47dd6c4f47f4a8206a03f37f1b3e0b02d4771c7c (patch)
treec4e92f1ed0b6d086e1d300155ff86b3a9ab79098 /src/nvim/api/buffer.c
parenta161559a006bcbc31a2eccbd96df3138e8bc3bc5 (diff)
downloadrneovim-47dd6c4f47f4a8206a03f37f1b3e0b02d4771c7c.tar.gz
rneovim-47dd6c4f47f4a8206a03f37f1b3e0b02d4771c7c.tar.bz2
rneovim-47dd6c4f47f4a8206a03f37f1b3e0b02d4771c7c.zip
fix(lint): remove redundant ternary operator
The value of `new_len` will never be '0' since `replacement.size` is checked against that early on.
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 3ab7e6b778..f906b426d7 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -624,7 +624,8 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
if (replacement.size == 1) {
firstlen += last_part_len;
}
- char *first = xmallocz(firstlen), *last = NULL;
+ char *first = xmallocz(firstlen);
+ char *last = NULL;
memcpy(first, str_at_start, (size_t)start_col);
memcpy(first+start_col, first_item.data, first_item.size);
memchrsub(first+start_col, NUL, NL, first_item.size);
@@ -637,7 +638,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
memcpy(last+last_item.size, str_at_end+end_col, last_part_len);
}
- char **lines = (new_len != 0) ? xcalloc(new_len, sizeof(char *)) : NULL;
+ char **lines = xcalloc(new_len, sizeof(char *));
lines[0] = first;
new_byte += (bcount_t)(first_item.size);
for (size_t i = 1; i < new_len-1; i++) {