diff src/memline.c @ 28357:86b6432aa1d8 v8.2.4704

patch 8.2.4704: using "else" after return or break increases indent Commit: https://github.com/vim/vim/commit/f26c16144ddb27642c09f2cf5271afd163b36306 Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> Date: Thu Apr 7 13:26:34 2022 +0100 patch 8.2.4704: using "else" after return or break increases indent Problem: Using "else" after return or break increases indent. Solution: Remove "else" and reduce indent. (Goc Dundar, closes https://github.com/vim/vim/issues/10099)
author Bram Moolenaar <Bram@vim.org>
date Thu, 07 Apr 2022 14:30:02 +0200
parents 427600f3b1c5
children 4dcccb2673fe
line wrap: on
line diff
--- a/src/memline.c
+++ b/src/memline.c
@@ -3165,94 +3165,93 @@ ml_append_int(
 		 */
 		break;
 	    }
-	    else			// pointer block full
+	    // pointer block full
+	    /*
+	     * split the pointer block
+	     * allocate a new pointer block
+	     * move some of the pointer into the new block
+	     * prepare for updating the parent block
+	     */
+	    for (;;)	// do this twice when splitting block 1
 	    {
+		hp_new = ml_new_ptr(mfp);
+		if (hp_new == NULL)	    // TODO: try to fix tree
+		    goto theend;
+		pp_new = (PTR_BL *)(hp_new->bh_data);
+
+		if (hp->bh_bnum != 1)
+		    break;
+
 		/*
-		 * split the pointer block
-		 * allocate a new pointer block
-		 * move some of the pointer into the new block
-		 * prepare for updating the parent block
+		 * if block 1 becomes full the tree is given an extra level
+		 * The pointers from block 1 are moved into the new block.
+		 * block 1 is updated to point to the new block
+		 * then continue to split the new block
 		 */
-		for (;;)	// do this twice when splitting block 1
-		{
-		    hp_new = ml_new_ptr(mfp);
-		    if (hp_new == NULL)	    // TODO: try to fix tree
-			goto theend;
-		    pp_new = (PTR_BL *)(hp_new->bh_data);
-
-		    if (hp->bh_bnum != 1)
-			break;
-
-		    /*
-		     * if block 1 becomes full the tree is given an extra level
-		     * The pointers from block 1 are moved into the new block.
-		     * block 1 is updated to point to the new block
-		     * then continue to split the new block
-		     */
-		    mch_memmove(pp_new, pp, (size_t)page_size);
-		    pp->pb_count = 1;
-		    pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
-		    pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count;
-		    pp->pb_pointer[0].pe_old_lnum = 1;
-		    pp->pb_pointer[0].pe_page_count = 1;
-		    mf_put(mfp, hp, TRUE, FALSE);   // release block 1
-		    hp = hp_new;		// new block is to be split
-		    pp = pp_new;
-		    CHECK(stack_idx != 0, _("stack_idx should be 0"));
-		    ip->ip_index = 0;
-		    ++stack_idx;	// do block 1 again later
-		}
-		/*
-		 * move the pointers after the current one to the new block
-		 * If there are none, the new entry will be in the new block.
-		 */
-		total_moved = pp->pb_count - pb_idx - 1;
-		if (total_moved)
-		{
-		    mch_memmove(&pp_new->pb_pointer[0],
+		mch_memmove(pp_new, pp, (size_t)page_size);
+		pp->pb_count = 1;
+		pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
+		pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count;
+		pp->pb_pointer[0].pe_old_lnum = 1;
+		pp->pb_pointer[0].pe_page_count = 1;
+		mf_put(mfp, hp, TRUE, FALSE);   // release block 1
+		hp = hp_new;		// new block is to be split
+		pp = pp_new;
+		CHECK(stack_idx != 0, _("stack_idx should be 0"));
+		ip->ip_index = 0;
+		++stack_idx;	// do block 1 again later
+	    }
+	    /*
+	     * move the pointers after the current one to the new block
+	     * If there are none, the new entry will be in the new block.
+	     */
+	    total_moved = pp->pb_count - pb_idx - 1;
+	    if (total_moved)
+	    {
+		mch_memmove(&pp_new->pb_pointer[0],
 				&pp->pb_pointer[pb_idx + 1],
 				(size_t)(total_moved) * sizeof(PTR_EN));
-		    pp_new->pb_count = total_moved;
-		    pp->pb_count -= total_moved - 1;
-		    pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right;
-		    pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right;
-		    pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right;
-		    if (lnum_right)
-			pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right;
-		}
-		else
-		{
-		    pp_new->pb_count = 1;
-		    pp_new->pb_pointer[0].pe_bnum = bnum_right;
-		    pp_new->pb_pointer[0].pe_line_count = line_count_right;
-		    pp_new->pb_pointer[0].pe_page_count = page_count_right;
-		    pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
-		}
-		pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
-		pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
-		pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
-		if (lnum_left)
-		    pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
-		lnum_left = 0;
-		lnum_right = 0;
-
-		/*
-		 * recompute line counts
-		 */
-		line_count_right = 0;
-		for (i = 0; i < (int)pp_new->pb_count; ++i)
-		    line_count_right += pp_new->pb_pointer[i].pe_line_count;
-		line_count_left = 0;
-		for (i = 0; i < (int)pp->pb_count; ++i)
-		    line_count_left += pp->pb_pointer[i].pe_line_count;
-
-		bnum_left = hp->bh_bnum;
-		bnum_right = hp_new->bh_bnum;
-		page_count_left = 1;
-		page_count_right = 1;
-		mf_put(mfp, hp, TRUE, FALSE);
-		mf_put(mfp, hp_new, TRUE, FALSE);
+		pp_new->pb_count = total_moved;
+		pp->pb_count -= total_moved - 1;
+		pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right;
+		pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right;
+		pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right;
+		if (lnum_right)
+		    pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right;
+	    }
+	    else
+	    {
+		pp_new->pb_count = 1;
+		pp_new->pb_pointer[0].pe_bnum = bnum_right;
+		pp_new->pb_pointer[0].pe_line_count = line_count_right;
+		pp_new->pb_pointer[0].pe_page_count = page_count_right;
+		pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
 	    }
+	    pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
+	    pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
+	    pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
+	    if (lnum_left)
+		pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
+	    lnum_left = 0;
+	    lnum_right = 0;
+
+	    /*
+	     * recompute line counts
+	     */
+	    line_count_right = 0;
+	    for (i = 0; i < (int)pp_new->pb_count; ++i)
+		line_count_right += pp_new->pb_pointer[i].pe_line_count;
+	    line_count_left = 0;
+	    for (i = 0; i < (int)pp->pb_count; ++i)
+		line_count_left += pp->pb_pointer[i].pe_line_count;
+
+	    bnum_left = hp->bh_bnum;
+	    bnum_right = hp_new->bh_bnum;
+	    page_count_left = 1;
+	    page_count_right = 1;
+	    mf_put(mfp, hp, TRUE, FALSE);
+	    mf_put(mfp, hp_new, TRUE, FALSE);
+
 	}
 
 	/*