Skip to content

Conversation

Konfekt
Copy link
Contributor

@Konfekt Konfekt commented Dec 15, 2024

See the discussion at lervag/vimtex#3054

@lervag
Copy link
Contributor

lervag commented Dec 15, 2024

I'm curious, on line 85, it says: "The most efficient is to call a compiled function without arguments:" - however, in my experimentation I really did not observe any noticable difference. I'm curious if anyone actually did, or if this is just based on someones hunch?

Perhaps we should also add a line above line 105 saying something like: The result values "=", "s" and "a" are more expensive, please see |fold-expr-slow|.; it may make the new section more discoverable.

@Konfekt
Copy link
Contributor Author

Konfekt commented Dec 15, 2024

I'm curious, on line 85, it says: "The most efficient is to call a compiled function without arguments:" - however, in my experimentation I really did not observe any noticable difference. I'm curious if anyone actually did, or if this is just based on someones hunch?

It links to

#  runtime/doc/vim9.txt (lines 1441-1453)
Calling a function in an expr option ~
							*expr-option-function*
The value of a few options, such as 'foldexpr', is an expression 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 define 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()

which makes sense as soon as one realizes that Bram added this file after implementing Vim9script.
I now rewrote it to make this clearer at the end of the slow section

@lervag
Copy link
Contributor

lervag commented Dec 15, 2024

Ok, I think this looks quite good now. 👍🏻

@chrisbra
Copy link
Member

thanks!

@chrisbra chrisbra closed this in 3920bb4 Dec 16, 2024
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Dec 17, 2024
…ation costs

closes: vim/vim#16224

vim/vim@3920bb4

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
mrowegawd pushed a commit to mrowegawd/neovim that referenced this pull request Jan 30, 2025
…ation costs

closes: vim/vim#16224

vim/vim@3920bb4

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants