Problem: in_vim9script() is called very frequently on the script
evaluation hot path, but is a cross-file function call whose
overhead dominates its trivial body.
Solution: Make in_vim9script() a "static inline" function in vim.h so it
is inlined at its call sites.
in_vim9script() only reads two globals, yet it accounted for about 9% of self time in a legacy script evaluation profile because it is invoked in a lot of call sites in the eval path and could not be inlined across translation units. Moving the body to a static inline function in vim.h guarded with #ifndef PROTO and removing the out-of-line definition eliminates the call overhead. Measured with retired instructions, this reduces legacy Vim script execution by roughly 3 to 4% in tight loops, function calls, builtin-heavy and string processing workloads; expression-bound editing such as :s//\=expr/g improves by about 2%. Vim9 script is unaffected. All in all, nothing groundbreaking, but a couple of percents improvements for a simple static inline sounds worthwhile to me.
https://github.com/vim/vim/pull/21215
(3 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()