comparison 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
comparison
equal deleted inserted replaced
28356:7225ec1e64cc 28357:86b6432aa1d8
3163 /* 3163 /*
3164 * We are finished, break the loop here. 3164 * We are finished, break the loop here.
3165 */ 3165 */
3166 break; 3166 break;
3167 } 3167 }
3168 else // pointer block full 3168 // pointer block full
3169 /*
3170 * split the pointer block
3171 * allocate a new pointer block
3172 * move some of the pointer into the new block
3173 * prepare for updating the parent block
3174 */
3175 for (;;) // do this twice when splitting block 1
3169 { 3176 {
3177 hp_new = ml_new_ptr(mfp);
3178 if (hp_new == NULL) // TODO: try to fix tree
3179 goto theend;
3180 pp_new = (PTR_BL *)(hp_new->bh_data);
3181
3182 if (hp->bh_bnum != 1)
3183 break;
3184
3170 /* 3185 /*
3171 * split the pointer block 3186 * if block 1 becomes full the tree is given an extra level
3172 * allocate a new pointer block 3187 * The pointers from block 1 are moved into the new block.
3173 * move some of the pointer into the new block 3188 * block 1 is updated to point to the new block
3174 * prepare for updating the parent block 3189 * then continue to split the new block
3175 */ 3190 */
3176 for (;;) // do this twice when splitting block 1 3191 mch_memmove(pp_new, pp, (size_t)page_size);
3177 { 3192 pp->pb_count = 1;
3178 hp_new = ml_new_ptr(mfp); 3193 pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
3179 if (hp_new == NULL) // TODO: try to fix tree 3194 pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count;
3180 goto theend; 3195 pp->pb_pointer[0].pe_old_lnum = 1;
3181 pp_new = (PTR_BL *)(hp_new->bh_data); 3196 pp->pb_pointer[0].pe_page_count = 1;
3182 3197 mf_put(mfp, hp, TRUE, FALSE); // release block 1
3183 if (hp->bh_bnum != 1) 3198 hp = hp_new; // new block is to be split
3184 break; 3199 pp = pp_new;
3185 3200 CHECK(stack_idx != 0, _("stack_idx should be 0"));
3186 /* 3201 ip->ip_index = 0;
3187 * if block 1 becomes full the tree is given an extra level 3202 ++stack_idx; // do block 1 again later
3188 * The pointers from block 1 are moved into the new block. 3203 }
3189 * block 1 is updated to point to the new block 3204 /*
3190 * then continue to split the new block 3205 * move the pointers after the current one to the new block
3191 */ 3206 * If there are none, the new entry will be in the new block.
3192 mch_memmove(pp_new, pp, (size_t)page_size); 3207 */
3193 pp->pb_count = 1; 3208 total_moved = pp->pb_count - pb_idx - 1;
3194 pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum; 3209 if (total_moved)
3195 pp->pb_pointer[0].pe_line_count = buf->b_ml.ml_line_count; 3210 {
3196 pp->pb_pointer[0].pe_old_lnum = 1; 3211 mch_memmove(&pp_new->pb_pointer[0],
3197 pp->pb_pointer[0].pe_page_count = 1;
3198 mf_put(mfp, hp, TRUE, FALSE); // release block 1
3199 hp = hp_new; // new block is to be split
3200 pp = pp_new;
3201 CHECK(stack_idx != 0, _("stack_idx should be 0"));
3202 ip->ip_index = 0;
3203 ++stack_idx; // do block 1 again later
3204 }
3205 /*
3206 * move the pointers after the current one to the new block
3207 * If there are none, the new entry will be in the new block.
3208 */
3209 total_moved = pp->pb_count - pb_idx - 1;
3210 if (total_moved)
3211 {
3212 mch_memmove(&pp_new->pb_pointer[0],
3213 &pp->pb_pointer[pb_idx + 1], 3212 &pp->pb_pointer[pb_idx + 1],
3214 (size_t)(total_moved) * sizeof(PTR_EN)); 3213 (size_t)(total_moved) * sizeof(PTR_EN));
3215 pp_new->pb_count = total_moved; 3214 pp_new->pb_count = total_moved;
3216 pp->pb_count -= total_moved - 1; 3215 pp->pb_count -= total_moved - 1;
3217 pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right; 3216 pp->pb_pointer[pb_idx + 1].pe_bnum = bnum_right;
3218 pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right; 3217 pp->pb_pointer[pb_idx + 1].pe_line_count = line_count_right;
3219 pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right; 3218 pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right;
3220 if (lnum_right) 3219 if (lnum_right)
3221 pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right; 3220 pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right;
3222 }
3223 else
3224 {
3225 pp_new->pb_count = 1;
3226 pp_new->pb_pointer[0].pe_bnum = bnum_right;
3227 pp_new->pb_pointer[0].pe_line_count = line_count_right;
3228 pp_new->pb_pointer[0].pe_page_count = page_count_right;
3229 pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
3230 }
3231 pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
3232 pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
3233 pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
3234 if (lnum_left)
3235 pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
3236 lnum_left = 0;
3237 lnum_right = 0;
3238
3239 /*
3240 * recompute line counts
3241 */
3242 line_count_right = 0;
3243 for (i = 0; i < (int)pp_new->pb_count; ++i)
3244 line_count_right += pp_new->pb_pointer[i].pe_line_count;
3245 line_count_left = 0;
3246 for (i = 0; i < (int)pp->pb_count; ++i)
3247 line_count_left += pp->pb_pointer[i].pe_line_count;
3248
3249 bnum_left = hp->bh_bnum;
3250 bnum_right = hp_new->bh_bnum;
3251 page_count_left = 1;
3252 page_count_right = 1;
3253 mf_put(mfp, hp, TRUE, FALSE);
3254 mf_put(mfp, hp_new, TRUE, FALSE);
3255 } 3221 }
3222 else
3223 {
3224 pp_new->pb_count = 1;
3225 pp_new->pb_pointer[0].pe_bnum = bnum_right;
3226 pp_new->pb_pointer[0].pe_line_count = line_count_right;
3227 pp_new->pb_pointer[0].pe_page_count = page_count_right;
3228 pp_new->pb_pointer[0].pe_old_lnum = lnum_right;
3229 }
3230 pp->pb_pointer[pb_idx].pe_bnum = bnum_left;
3231 pp->pb_pointer[pb_idx].pe_line_count = line_count_left;
3232 pp->pb_pointer[pb_idx].pe_page_count = page_count_left;
3233 if (lnum_left)
3234 pp->pb_pointer[pb_idx].pe_old_lnum = lnum_left;
3235 lnum_left = 0;
3236 lnum_right = 0;
3237
3238 /*
3239 * recompute line counts
3240 */
3241 line_count_right = 0;
3242 for (i = 0; i < (int)pp_new->pb_count; ++i)
3243 line_count_right += pp_new->pb_pointer[i].pe_line_count;
3244 line_count_left = 0;
3245 for (i = 0; i < (int)pp->pb_count; ++i)
3246 line_count_left += pp->pb_pointer[i].pe_line_count;
3247
3248 bnum_left = hp->bh_bnum;
3249 bnum_right = hp_new->bh_bnum;
3250 page_count_left = 1;
3251 page_count_right = 1;
3252 mf_put(mfp, hp, TRUE, FALSE);
3253 mf_put(mfp, hp_new, TRUE, FALSE);
3254
3256 } 3255 }
3257 3256
3258 /* 3257 /*
3259 * Safety check: fallen out of for loop? 3258 * Safety check: fallen out of for loop?
3260 */ 3259 */