aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-19 09:51:59 +0800
committerGitHub <noreply@github.com>2023-01-19 09:51:59 +0800
commit45dc0f3454d826c42efdcd841953b5e7e613bc5e (patch)
tree3a41b3930feb90624040f5269146fceaab295366 /src/nvim/ops.c
parentf8669e8a181abad98229d97439a9cafe8c32fc06 (diff)
downloadrneovim-45dc0f3454d826c42efdcd841953b5e7e613bc5e.tar.gz
rneovim-45dc0f3454d826c42efdcd841953b5e7e613bc5e.tar.bz2
rneovim-45dc0f3454d826c42efdcd841953b5e7e613bc5e.zip
vim-patch:9.0.1221: code is indented more than necessary (#21891)
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11833) https://github.com/vim/vim/commit/f97a295ccaa9803367f3714cdefce4e2283c771d Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index c87aa596c3..e08cd082d9 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1193,18 +1193,20 @@ static void put_reedit_in_typebuf(int silent)
{
char_u buf[3];
- if (restart_edit != NUL) {
- if (restart_edit == 'V') {
- buf[0] = 'g';
- buf[1] = 'R';
- buf[2] = NUL;
- } else {
- buf[0] = (char_u)(restart_edit == 'I' ? 'i' : restart_edit);
- buf[1] = NUL;
- }
- if (ins_typebuf((char *)buf, REMAP_NONE, 0, true, silent) == OK) {
- restart_edit = NUL;
- }
+ if (restart_edit == NUL) {
+ return;
+ }
+
+ if (restart_edit == 'V') {
+ buf[0] = 'g';
+ buf[1] = 'R';
+ buf[2] = NUL;
+ } else {
+ buf[0] = (char_u)(restart_edit == 'I' ? 'i' : restart_edit);
+ buf[1] = NUL;
+ }
+ if (ins_typebuf((char *)buf, REMAP_NONE, 0, true, silent) == OK) {
+ restart_edit = NUL;
}
}
@@ -2574,12 +2576,14 @@ void free_register(yankreg_T *reg)
FUNC_ATTR_NONNULL_ALL
{
set_yreg_additional_data(reg, NULL);
- if (reg->y_array != NULL) {
- for (size_t i = reg->y_size; i-- > 0;) { // from y_size - 1 to 0 included
- xfree(reg->y_array[i]);
- }
- XFREE_CLEAR(reg->y_array);
+ if (reg->y_array == NULL) {
+ return;
+ }
+
+ for (size_t i = reg->y_size; i-- > 0;) { // from y_size - 1 to 0 included
+ xfree(reg->y_array[i]);
}
+ XFREE_CLEAR(reg->y_array);
}
/// Yanks the text between "oap->start" and "oap->end" into a yank register.