EnumerableMap vs 2-array performance?

If you wanted to maintain two lists that will always be the same size (an address list and a uint list) I am looking for the best way to do this. Ordering of entries is not important for my case.

Would it be more efficient to use two arrays (adding and removing from eachother in tandem) or use OZ's EnumerableMap?

From my limited knowledge, the O(1) for deletes in EnumerableMap is a direct performance improvement over the arrays method (which will be O(n) for deletes IIRC). I think this is the only significant difference there, so the time complexities certainly seem to favor EnumerableMap.

Though, the main bottleneck in Solidity is usually storage. How would the storage footprint different between these two?

1 Like

Hi @kiko!

Great question. Based on my understanding, the answer would be that it depends on what goes into the array or mapping. Fixed size arrays would offer greater storage efficiency over mappings for smaller types like uint8 and byte.

There is a great resource here delving into storage costs of arrays and other data structures.

If you'd like, feel free to share more information or a code example with your intended use case.