mirror of
https://github.com/neovim/neovim.git
synced 2025-10-12 04:46:10 +00:00
vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799)
Problem: too many STRLEN calls when getting a memline
Solution: Optimize calls to STRLEN(), add a few functions in memline.c
that return the byte length instead of relying on STRLEN()
(John Marriott)
closes: vim/vim#14052
02d7a6c6cf
Cherry-pick line break changes from patch 8.1.0226.
Cherry-pick ml_line_len from patch 8.1.0579.
Cherry-pick test_comments.vim change from patch 9.1.0153.
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -514,3 +514,15 @@ char *get_cursor_pos_ptr(void)
|
||||
{
|
||||
return ml_get_buf(curbuf, curwin->w_cursor.lnum) + curwin->w_cursor.col;
|
||||
}
|
||||
|
||||
/// @return length (excluding the NUL) of the cursor line.
|
||||
colnr_T get_cursor_line_len(void)
|
||||
{
|
||||
return ml_get_buf_len(curbuf, curwin->w_cursor.lnum);
|
||||
}
|
||||
|
||||
/// @return length (excluding the NUL) of the cursor position.
|
||||
colnr_T get_cursor_pos_len(void)
|
||||
{
|
||||
return ml_get_buf_len(curbuf, curwin->w_cursor.lnum) - curwin->w_cursor.col;
|
||||
}
|
||||
|
Reference in New Issue
Block a user