tact
tact copied to clipboard
Optimize cell creation from `Struct.toCell()` compared to `Builder` methods
Struct.toCell() should produce the same gas consumption as manual cell creation with Builder methods. However, when we port logic from manual creation to toCell we lose gas on it. Maybe we should try to optimize it with compiler-level FunC inlining.
We can use wallet-v4 Tact FunC version port in benchmarks as an example for this issue
Here is gist with wallet-v4 implementation using native builder methods
Here is diff, compared with Struct.toCell() version:
Related issue: #2051. Duplicating my comment from here:
For instance, inlining "struct constructors" would save gas but break examples like
get fun create(v: Int): S {
return S{v3: v.inc(), v2: v.inc(), v1: v.inc()}; // NOTE: Inverted order!
}
because S's fields are passed to the constructor in the order they appear in the code above, but after inlining the order will be reversed