Mercurial > vim
comparison src/undo.c @ 31827:1009c33499e7 v9.0.1246
patch 9.0.1246: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/142ed77898facf8f423fee2717efee1749c55f9a
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Jan 26 12:00:00 2023 +0000
patch 9.0.1246: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11887)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 26 Jan 2023 13:15:04 +0100 |
parents | 53c3df37a2b0 |
children | bb5458706799 |
comparison
equal
deleted
inserted
replaced
31826:06619adfbcdd | 31827:1009c33499e7 |
---|---|
1162 static char_u * | 1162 static char_u * |
1163 read_string_decrypt(bufinfo_T *bi, int len) | 1163 read_string_decrypt(bufinfo_T *bi, int len) |
1164 { | 1164 { |
1165 char_u *ptr = alloc(len + 1); | 1165 char_u *ptr = alloc(len + 1); |
1166 | 1166 |
1167 if (ptr != NULL) | 1167 if (ptr == NULL) |
1168 { | 1168 return NULL; |
1169 if (len > 0 && undo_read(bi, ptr, len) == FAIL) | 1169 |
1170 { | 1170 if (len > 0 && undo_read(bi, ptr, len) == FAIL) |
1171 vim_free(ptr); | 1171 { |
1172 return NULL; | 1172 vim_free(ptr); |
1173 } | 1173 return NULL; |
1174 // In case there are text properties there already is a NUL, but | 1174 } |
1175 // checking for that is more expensive than just adding a dummy byte. | 1175 // In case there are text properties there already is a NUL, but |
1176 ptr[len] = NUL; | 1176 // checking for that is more expensive than just adding a dummy byte. |
1177 ptr[len] = NUL; | |
1177 #ifdef FEAT_CRYPT | 1178 #ifdef FEAT_CRYPT |
1178 if (bi->bi_state != NULL && bi->bi_buffer == NULL) | 1179 if (bi->bi_state != NULL && bi->bi_buffer == NULL) |
1179 crypt_decode_inplace(bi->bi_state, ptr, len, FALSE); | 1180 crypt_decode_inplace(bi->bi_state, ptr, len, FALSE); |
1180 #endif | 1181 #endif |
1181 } | |
1182 return ptr; | 1182 return ptr; |
1183 } | 1183 } |
1184 | 1184 |
1185 /* | 1185 /* |
1186 * Writes the (not encrypted) header and initializes encryption if needed. | 1186 * Writes the (not encrypted) header and initializes encryption if needed. |
3508 * (this is used externally for crossing a line while in insert mode) | 3508 * (this is used externally for crossing a line while in insert mode) |
3509 */ | 3509 */ |
3510 void | 3510 void |
3511 u_clearline(void) | 3511 u_clearline(void) |
3512 { | 3512 { |
3513 if (curbuf->b_u_line_ptr.ul_line != NULL) | 3513 if (curbuf->b_u_line_ptr.ul_line == NULL) |
3514 { | 3514 return; |
3515 VIM_CLEAR(curbuf->b_u_line_ptr.ul_line); | 3515 |
3516 curbuf->b_u_line_ptr.ul_len = 0; | 3516 VIM_CLEAR(curbuf->b_u_line_ptr.ul_line); |
3517 curbuf->b_u_line_lnum = 0; | 3517 curbuf->b_u_line_ptr.ul_len = 0; |
3518 } | 3518 curbuf->b_u_line_lnum = 0; |
3519 } | 3519 } |
3520 | 3520 |
3521 /* | 3521 /* |
3522 * Implementation of the "U" command. | 3522 * Implementation of the "U" command. |
3523 * Differentiation from vi: "U" can be undone with the next "U". | 3523 * Differentiation from vi: "U" can be undone with the next "U". |
3724 * "undotree()" function | 3724 * "undotree()" function |
3725 */ | 3725 */ |
3726 void | 3726 void |
3727 f_undotree(typval_T *argvars UNUSED, typval_T *rettv) | 3727 f_undotree(typval_T *argvars UNUSED, typval_T *rettv) |
3728 { | 3728 { |
3729 if (rettv_dict_alloc(rettv) == OK) | 3729 if (rettv_dict_alloc(rettv) == FAIL) |
3730 { | 3730 return; |
3731 dict_T *dict = rettv->vval.v_dict; | 3731 |
3732 list_T *list; | 3732 dict_T *dict = rettv->vval.v_dict; |
3733 | 3733 list_T *list; |
3734 dict_add_number(dict, "synced", (long)curbuf->b_u_synced); | 3734 |
3735 dict_add_number(dict, "seq_last", curbuf->b_u_seq_last); | 3735 dict_add_number(dict, "synced", (long)curbuf->b_u_synced); |
3736 dict_add_number(dict, "save_last", curbuf->b_u_save_nr_last); | 3736 dict_add_number(dict, "seq_last", curbuf->b_u_seq_last); |
3737 dict_add_number(dict, "seq_cur", curbuf->b_u_seq_cur); | 3737 dict_add_number(dict, "save_last", curbuf->b_u_save_nr_last); |
3738 dict_add_number(dict, "time_cur", (long)curbuf->b_u_time_cur); | 3738 dict_add_number(dict, "seq_cur", curbuf->b_u_seq_cur); |
3739 dict_add_number(dict, "save_cur", curbuf->b_u_save_nr_cur); | 3739 dict_add_number(dict, "time_cur", (long)curbuf->b_u_time_cur); |
3740 | 3740 dict_add_number(dict, "save_cur", curbuf->b_u_save_nr_cur); |
3741 list = list_alloc(); | 3741 |
3742 if (list != NULL) | 3742 list = list_alloc(); |
3743 { | 3743 if (list != NULL) |
3744 u_eval_tree(curbuf->b_u_oldhead, list); | 3744 { |
3745 dict_add_list(dict, "entries", list); | 3745 u_eval_tree(curbuf->b_u_oldhead, list); |
3746 } | 3746 dict_add_list(dict, "entries", list); |
3747 } | 3747 } |
3748 } | 3748 } |
3749 | 3749 |
3750 #endif | 3750 #endif |