Inlining
When compiling a contract in LIGO, declarations will get inlined if they are only used once and are pure, that is, devoid of side effects.
Inlining often results in larger contracts and is therefore not aggressively done. In some cases, you might want to override the default behaviour of LIGO and force inlining, as long as the expression considered for inlining is pure, that is, it does not cause side effects, like possibly failing or a emitting an operation.
To force inlining you can use the @inline
decorator.
To measure the difference between inlining and without inlining, let
us assume that the above code is inside the file inline.jsligo
and
run the command: ligo info measure-contract inline.jsligo
with and
without the decorator @inline
. We obtain the following results
With inlining | 46 bytes |
Without inlining | 97 bytes |
Note that these results can change due to ongoing work to optimise output of the LIGO compiler.