diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-01 19:43:52 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-01 19:43:52 +0100 |
commit | a4e0b9785e409e9e660171cea76dfcc5fdafad9b (patch) | |
tree | 3323913d9bdc9cd09029b1314a77c4a5e8191bbf /runtime | |
parent | b850c39676db21c6f1aa3afed0e2e48d407dd60e (diff) |
patch 9.0.0634: evaluating "expr" options has more overhead than neededv9.0.0634
Problem: Evaluating "expr" options has more overhead than needed.
Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr',
"expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr',
'formatexpr', 'indentexpr' and 'charconvert'.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/diff.txt | 6 | ||||
-rw-r--r-- | runtime/doc/options.txt | 24 | ||||
-rw-r--r-- | runtime/doc/print.txt | 11 |
3 files changed, 32 insertions, 9 deletions
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index a66df1e273..e5321c586d 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -376,6 +376,9 @@ Additionally, 'diffexpr' should take care of "icase" and "iwhite" in the 'diffopt' option. 'diffexpr' cannot change the value of 'lines' and 'columns'. +The advantage of using a function call without arguments is that it is faster, +see |expr-option-function|. + Example (this does almost the same as 'diffexpr' being empty): > set diffexpr=MyDiff() @@ -441,6 +444,9 @@ will have the same effect. These variables are set to the file names used: v:fname_diff patch file v:fname_out resulting patched file +The advantage of using a function call without arguments is that it is faster, +see |expr-option-function|. + Example (this does the same as 'patchexpr' being empty): > set patchexpr=MyPatch() diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4ea75ba2db..aa69dd1e91 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1626,6 +1626,9 @@ A jump table for the options with a short description can be found at |Q_op|. Note that v:charconvert_from and v:charconvert_to may be different from 'encoding'. Vim internally uses UTF-8 instead of UCS-2 or UCS-4. + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + Encryption is not done by Vim when using 'charconvert'. If you want to encrypt the file after conversion, 'charconvert' should take care of this. @@ -3664,6 +3667,9 @@ A jump table for the options with a short description can be found at |Q_op|. < This will invoke the mylang#Format() function in the autoload/mylang.vim file in 'runtimepath'. |autoload| + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression is also evaluated when 'textwidth' is set and adding text beyond that limit. This happens under the same conditions as when internal formatting is used. Make sure the cursor is kept in the @@ -4534,11 +4540,14 @@ A jump table for the options with a short description can be found at |Q_op|. If the expression starts with s: or |<SID>|, then it is replaced with the script ID (|local-function|). Example: > - set includeexpr=s:MyIncludeExpr(v:fname) - set includeexpr=<SID>SomeIncludeExpr(v:fname) + set includeexpr=s:MyIncludeExpr() + set includeexpr=<SID>SomeIncludeExpr() < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + It is more efficient if the value is just a function call without + arguments, see |expr-option-function|. + The expression will be evaluated in the |sandbox| when set from a modeline, see |sandbox-option|. This option cannot be set in a modeline when 'modelineexpr' is off. @@ -4620,6 +4629,9 @@ A jump table for the options with a short description can be found at |Q_op|. < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression must return the number of spaces worth of indent. It can return "-1" to keep the current indent (this means 'autoindent' is used for the indent). @@ -7470,9 +7482,11 @@ A jump table for the options with a short description can be found at |Q_op|. The file is used for all languages. expr:{expr} Evaluate expression {expr}. Use a function to avoid - trouble with spaces. |v:val| holds the badly spelled - word. The expression must evaluate to a List of - Lists, each with a suggestion and a score. + trouble with spaces. Best is to call a function + without arguments, see |expr-option-function|. + |v:val| holds the badly spelled word. The expression + must evaluate to a List of Lists, each with a + suggestion and a score. Example: [['the', 33], ['that', 44]] ~ Set 'verbose' and use |z=| to see the scores that the diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index 2774e981f6..9f8bb20879 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -158,13 +158,16 @@ currently specified printdevice: > If you change this option, using a function is an easy way to avoid having to escape all the spaces. Example: > - :set printexpr=PrintFile(v:fname_in) - :function PrintFile(fname) - : call system("ghostview " .. a:fname) - : call delete(a:fname) + :set printexpr=PrintFile() + :function PrintFile() + : call system("ghostview " .. v:fname_in) + : call delete(v:fname_in) : return v:shell_error :endfunc +It is more efficient if the option is set to just a function call, +see |expr-option-function|. + Be aware that some print programs return control before they have read the file. If you delete the file too soon it will not be printed. These programs usually offer an option to have them remove the file when printing is done. |