Mercurial > vim
comparison src/eval.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 | 5c1a025192ed |
children | 5b25ec43f208 |
comparison
equal
deleted
inserted
replaced
34531:0591aba1489d | 34532:64edf95a833a |
---|---|
6466 if (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count) | 6466 if (error || pos.lnum <= 0 || pos.lnum > curbuf->b_ml.ml_line_count) |
6467 return NULL; // invalid line number | 6467 return NULL; // invalid line number |
6468 if (charcol) | 6468 if (charcol) |
6469 len = (long)mb_charlen(ml_get(pos.lnum)); | 6469 len = (long)mb_charlen(ml_get(pos.lnum)); |
6470 else | 6470 else |
6471 len = (long)STRLEN(ml_get(pos.lnum)); | 6471 len = (long)ml_get_len(pos.lnum); |
6472 | 6472 |
6473 // Get the column number | 6473 // Get the column number |
6474 // We accept "$" for the column number: last column. | 6474 // We accept "$" for the column number: last column. |
6475 li = list_find(l, 1L); | 6475 li = list_find(l, 1L); |
6476 if (li != NULL && li->li_tv.v_type == VAR_STRING | 6476 if (li != NULL && li->li_tv.v_type == VAR_STRING |
6572 { | 6572 { |
6573 pos.lnum = curwin->w_cursor.lnum; | 6573 pos.lnum = curwin->w_cursor.lnum; |
6574 if (charcol) | 6574 if (charcol) |
6575 pos.col = (colnr_T)mb_charlen(ml_get_curline()); | 6575 pos.col = (colnr_T)mb_charlen(ml_get_curline()); |
6576 else | 6576 else |
6577 pos.col = (colnr_T)STRLEN(ml_get_curline()); | 6577 pos.col = ml_get_curline_len(); |
6578 } | 6578 } |
6579 return &pos; | 6579 return &pos; |
6580 } | 6580 } |
6581 if (in_vim9script()) | 6581 if (in_vim9script()) |
6582 semsg(_(e_invalid_value_for_line_number_str), name); | 6582 semsg(_(e_invalid_value_for_line_number_str), name); |