When to use inline function?

#1

For js server functions, will making the function inline improve the performance when this function is being called by another js server function?

0 Likes

#2

I believe so since you stay in the same language according to the documentation:

Methods can also be marked as “inline,” which is a hint that the method should be called in the fastest way possible. Typically if the method is being called from and implemented in the same language, a direct language-level call is made rather than a generalized action call.

The upside of inline is that the calls are much faster. The downside is that there is no logging of inline calls so the time and other resources used by the inline call will be lumped with the calling function. Inline should only be used for trivial methods, typically ones that perform quick processing on their arguments.

Note that if an inline function is called from a different language, the inline will not be a direct call but may still not log, or may be entirely ignored if called in the client and implemented in the server.

The inline modifier can also be used at the type level, which implies that all its declared methods are inline. However, inline does not automatically extend to types that mix in an inline type; if the child type is meant to be inline as well, it must declare it.

0 Likes