comparison src/evalfunc.c @ 34532:64edf95a833a v9.1.0168

patch 9.1.0168: too many STRLEN() calls Commit: https://github.com/vim/vim/commit/bfcc895482c717c9f6d86890d789ec739c3016b4 Author: John Marriott <basilisk@internode.on.net> Date: Mon Mar 11 22:04:45 2024 +0100 patch 9.1.0168: too many STRLEN() calls Problem: too many STRLEN() calls Solution: Make use of ml_get_len() calls instead (John Marriott) closes: #14123 Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 11 Mar 2024 22:15:03 +0100
parents c770ad7ac4ab
children 5b25ec43f208
comparison
equal deleted inserted replaced
34531:0591aba1489d 34532:64edf95a833a
3635 { 3635 {
3636 if (fp->col == MAXCOL) 3636 if (fp->col == MAXCOL)
3637 { 3637 {
3638 // '> can be MAXCOL, get the length of the line then 3638 // '> can be MAXCOL, get the length of the line then
3639 if (fp->lnum <= curbuf->b_ml.ml_line_count) 3639 if (fp->lnum <= curbuf->b_ml.ml_line_count)
3640 col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1; 3640 col = ml_get_len(fp->lnum) + 1;
3641 else 3641 else
3642 col = MAXCOL; 3642 col = MAXCOL;
3643 } 3643 }
3644 else 3644 else
3645 { 3645 {
11132 lnum = tv_get_lnum(argvars); // -1 on type error 11132 lnum = tv_get_lnum(argvars); // -1 on type error
11133 col = (linenr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error 11133 col = (linenr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
11134 trans = (int)tv_get_bool_chk(&argvars[2], &transerr); 11134 trans = (int)tv_get_bool_chk(&argvars[2], &transerr);
11135 11135
11136 if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count 11136 if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
11137 && col >= 0 && col < (long)STRLEN(ml_get(lnum))) 11137 && col >= 0 && col < (long)ml_get_len(lnum))
11138 id = syn_get_id(curwin, lnum, col, trans, NULL, FALSE); 11138 id = syn_get_id(curwin, lnum, col, trans, NULL, FALSE);
11139 #endif 11139 #endif
11140 11140
11141 rettv->vval.v_number = id; 11141 rettv->vval.v_number = id;
11142 } 11142 }
11309 CLEAR_FIELD(str); 11309 CLEAR_FIELD(str);
11310 11310
11311 if (rettv_list_alloc(rettv) == OK) 11311 if (rettv_list_alloc(rettv) == OK)
11312 { 11312 {
11313 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count 11313 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
11314 && col >= 0 && col <= (long)STRLEN(ml_get(lnum)) 11314 && col >= 0 && col <= (long)ml_get_len(lnum)
11315 && curwin->w_p_cole > 0) 11315 && curwin->w_p_cole > 0)
11316 { 11316 {
11317 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, FALSE); 11317 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, FALSE);
11318 syntax_flags = get_syntax_info(&matchid); 11318 syntax_flags = get_syntax_info(&matchid);
11319 11319
11366 #ifdef FEAT_SYN_HL 11366 #ifdef FEAT_SYN_HL
11367 lnum = tv_get_lnum(argvars); // -1 on type error 11367 lnum = tv_get_lnum(argvars); // -1 on type error
11368 col = (colnr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error 11368 col = (colnr_T)tv_get_number(&argvars[1]) - 1; // -1 on type error
11369 11369
11370 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count 11370 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
11371 && col >= 0 && col <= (long)STRLEN(ml_get(lnum)) 11371 && col >= 0 && col <= (long)ml_get_len(lnum)
11372 && rettv_list_alloc(rettv) == OK) 11372 && rettv_list_alloc(rettv) == OK)
11373 { 11373 {
11374 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE); 11374 (void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE);
11375 for (i = 0; ; ++i) 11375 for (i = 0; ; ++i)
11376 { 11376 {
11544 // Limit the column to a valid value, getvvcol() doesn't check. 11544 // Limit the column to a valid value, getvvcol() doesn't check.
11545 if (fp->col < 0) 11545 if (fp->col < 0)
11546 fp->col = 0; 11546 fp->col = 0;
11547 else 11547 else
11548 { 11548 {
11549 len = (int)STRLEN(ml_get(fp->lnum)); 11549 len = (int)ml_get_len(fp->lnum);
11550 if (fp->col > len) 11550 if (fp->col > len)
11551 fp->col = len; 11551 fp->col = len;
11552 } 11552 }
11553 getvvcol(curwin, fp, &vcol_start, NULL, &vcol_end); 11553 getvvcol(curwin, fp, &vcol_start, NULL, &vcol_end);
11554 ++vcol_start; 11554 ++vcol_start;