diff options
author | =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> | 2022-04-07 13:26:34 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-07 13:26:34 +0100 |
commit | f26c16144ddb27642c09f2cf5271afd163b36306 (patch) | |
tree | d4cfbbd4b403ba63982435b61a41fa71755f1716 /src/memline.c | |
parent | cb49a1d934d38cbc0d445af59b71ffe45cbcae75 (diff) |
patch 8.2.4704: using "else" after return or break increases indentv8.2.4704
Problem: Using "else" after return or break increases indent.
Solution: Remove "else" and reduce indent. (Goc Dundar, closes #10099)
Diffstat (limited to 'src/memline.c')
-rw-r--r-- | src/memline.c | 159 |
1 files changed, 79 insertions, 80 deletions
diff --git a/src/memline.c b/src/memline.c index abd2360ae8..f38e029bd1 100644 --- 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 { - /* - * 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); + 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 (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. + * 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 */ - 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); + } /* |