Dear experts
Please help me to understand how can I efficiently store a (memory) array into (storage) array; With minimal gas costs.
Google says nothing about it https://stackoverflow.com/questions/48646948/how-do-i-efficiently-replace-a-storage-array-in-solidity
Chat gpt says something useful but I don't think it is useful
//Step1 I have storage mapping
mapping(uint8 => uint8[]) public mapNodeToShards;
//Step2 I calculate nodeShardsSet
uint8[][] memory nodeShardsSet = ...;
// Step3 save to storage , only modified nodes
for(uint node=0;node if(nodeModifiedSet[node]>0) {
mapNodeToShards[node] = nodeShardsSet[node];
}
}
Can I do step3 more efficiently?
mapNodeToShards[node] = nodeShardsSet[node];
}
}
Can I do step3 more efficiently?
Aug 29, 2023, 12:27 PM
Below is the chatgpt answer (not very useful)
Aug 29, 2023, 12:27 PM