patch 9.0.0632: calling a function from an "expr" option has overhead

Problem:    Calling a function from an "expr" option has too much overhead.
Solution:   Add call_simple_func() and use it for 'foldexpr'
This commit is contained in:
Bram Moolenaar
2022-10-01 15:32:46 +01:00
parent 145d1fd910
commit 87b4e5c5db
8 changed files with 144 additions and 11 deletions

View File

@ -1410,6 +1410,21 @@ to a Vim9 function:
'three'
]
Calling a function in an expr option ~
*expr-option-function*
A few options, such as 'foldexpr', are an expresison that is evaluated to get
a value. The evaluation can have quite a bit of overhead. One way to
minimize the overhead, and also to keep the option value very simple, is to
defined a compiled function and set the option to call it without arguments.
Example: >
vim9script
def MyFoldFunc(): any
... compute fold level for line v:lnum
return level
enddef
set foldexpr=s:MyFoldFunc()
==============================================================================
4. Types *vim9-types*