External functions are gas expensive. The RealmDiamond(s.realmDiamond).getAlchemicaAddresses() function call can be made one time outside the loop.
State reads are also gas expensive. Line 214 read all state from the InstallationType struct and in line 220 reads more of it from state from storage repeatedly. I think you can use the installationType memory variable to read the state on line 220 instead of reading from contract storage.
It might be better not to read the entire InstallationType from contract storage to memory because not all of its state variables are needed.
The
craftInstallations
has this code: https://github.com/aavegotchi/aavegotchi-realm-diamond/blob/cee38d37307c49dc41cdb737a962d5d313c1cd4f/contracts/InstallationDiamond/facets/InstallationFacet.sol#L214-L222External functions are gas expensive. The
RealmDiamond(s.realmDiamond).getAlchemicaAddresses()
function call can be made one time outside the loop.State reads are also gas expensive. Line 214 read all state from the
InstallationType
struct and in line 220 reads more of it from state from storage repeatedly. I think you can use theinstallationType
memory variable to read the state on line 220 instead of reading from contract storage.It might be better not to read the entire
InstallationType
from contract storage to memory because not all of its state variables are needed.