patch 9.0.0916: getbufline() is inefficient for getting a single line

Problem:    getbufline() is inefficient for getting a single line.
Solution:   Add getbufoneline().
This commit is contained in:
Bram Moolenaar
2022-11-21 19:57:04 +00:00
parent 2996773276
commit ce30ccc06a
8 changed files with 52 additions and 6 deletions

View File

@ -208,6 +208,7 @@ get({func}, {what}) any get property of funcref/partial {func}
getbufinfo([{buf}]) List information about buffers
getbufline({buf}, {lnum} [, {end}])
List lines {lnum} to {end} of buffer {buf}
getbufoneline({buf}, {lnum}) String line {lnum} of buffer {buf}
getbufvar({buf}, {varname} [, {def}])
any variable {varname} in buffer {buf}
getchangelist([{buf}]) List list of change list items
@ -3204,7 +3205,8 @@ getbufinfo([{dict}])
getbufline({buf}, {lnum} [, {end}])
Return a |List| with the lines starting from {lnum} to {end}
(inclusive) in the buffer {buf}. If {end} is omitted, a
|List| with only the line {lnum} is returned.
|List| with only the line {lnum} is returned. See
`getbufoneline()` for only getting the line.
For the use of {buf}, see |bufname()| above.
@ -3227,6 +3229,11 @@ getbufline({buf}, {lnum} [, {end}])
< Can also be used as a |method|: >
GetBufnr()->getbufline(lnum)
<
*getbufoneline()*
getbufoneline({buf}, {lnum})
Just like `getbufline()` but only get one line and return it
as a string.
getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
The result is the value of option or local buffer variable
@ -3771,7 +3778,8 @@ getline({lnum} [, {end}])
< Can also be used as a |method|: >
ComputeLnum()->getline()
< To get lines from another buffer see |getbufline()|
< To get lines from another buffer see |getbufline()| and
|getbufoneline()|
getloclist({nr} [, {what}]) *getloclist()*
Returns a |List| with all the entries in the location list for