comparison src/userfunc.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 a98ef841fd01
children 16025ef158bf
comparison
equal deleted inserted replaced
31826:06619adfbcdd 31827:1009c33499e7
768 * is compiled or called later. 768 * is compiled or called later.
769 */ 769 */
770 static void 770 static void
771 function_using_block_scopes(ufunc_T *fp, cstack_T *cstack) 771 function_using_block_scopes(ufunc_T *fp, cstack_T *cstack)
772 { 772 {
773 if (cstack != NULL && cstack->cs_idx >= 0) 773 if (cstack == NULL || cstack->cs_idx < 0)
774 { 774 return;
775 int count = cstack->cs_idx + 1; 775
776 int i; 776 int count = cstack->cs_idx + 1;
777 777 int i;
778 fp->uf_block_ids = ALLOC_MULT(int, count); 778
779 if (fp->uf_block_ids != NULL) 779 fp->uf_block_ids = ALLOC_MULT(int, count);
780 { 780 if (fp->uf_block_ids != NULL)
781 mch_memmove(fp->uf_block_ids, cstack->cs_block_id, 781 {
782 sizeof(int) * count); 782 mch_memmove(fp->uf_block_ids, cstack->cs_block_id,
783 fp->uf_block_depth = count; 783 sizeof(int) * count);
784 } 784 fp->uf_block_depth = count;
785 785 }
786 // Set flag in each block to indicate a function was defined. This 786
787 // is used to keep the variable when leaving the block, see 787 // Set flag in each block to indicate a function was defined. This
788 // hide_script_var(). 788 // is used to keep the variable when leaving the block, see
789 for (i = 0; i <= cstack->cs_idx; ++i) 789 // hide_script_var().
790 cstack->cs_flags[i] |= CSF_FUNC_DEF; 790 for (i = 0; i <= cstack->cs_idx; ++i)
791 } 791 cstack->cs_flags[i] |= CSF_FUNC_DEF;
792 } 792 }
793 793
794 /* 794 /*
795 * Read the body of a function, put every line in "newlines". 795 * Read the body of a function, put every line in "newlines".
796 * This stops at "}", "endfunction" or "enddef". 796 * This stops at "}", "endfunction" or "enddef".
2431 // Return if it was already virtually deleted. 2431 // Return if it was already virtually deleted.
2432 if (fp->uf_flags & FC_DEAD) 2432 if (fp->uf_flags & FC_DEAD)
2433 return FALSE; 2433 return FALSE;
2434 2434
2435 hi = hash_find(&func_hashtab, UF2HIKEY(fp)); 2435 hi = hash_find(&func_hashtab, UF2HIKEY(fp));
2436 if (!HASHITEM_EMPTY(hi)) 2436 if (HASHITEM_EMPTY(hi))
2437 { 2437 return FALSE;
2438 // When there is a def-function index do not actually remove the 2438
2439 // function, so we can find the index when defining the function again. 2439 // When there is a def-function index do not actually remove the
2440 // Do remove it when it's a copy. 2440 // function, so we can find the index when defining the function again.
2441 if (fp->uf_def_status == UF_COMPILED && (fp->uf_flags & FC_COPY) == 0) 2441 // Do remove it when it's a copy.
2442 { 2442 if (fp->uf_def_status == UF_COMPILED && (fp->uf_flags & FC_COPY) == 0)
2443 fp->uf_flags |= FC_DEAD; 2443 {
2444 return FALSE; 2444 fp->uf_flags |= FC_DEAD;
2445 } 2445 return FALSE;
2446 hash_remove(&func_hashtab, hi, "remove function"); 2446 }
2447 fp->uf_flags |= FC_DELETED; 2447 hash_remove(&func_hashtab, hi, "remove function");
2448 return TRUE; 2448 fp->uf_flags |= FC_DELETED;
2449 } 2449 return TRUE;
2450 return FALSE;
2451 } 2450 }
2452 2451
2453 static void 2452 static void
2454 func_clear_items(ufunc_T *fp) 2453 func_clear_items(ufunc_T *fp)
2455 { 2454 {