Compare two gigantic maps

Hello,

I have some data stored in maps, that can have 10k keys, but do not change often.

if I ask old_map == new_map, does the BEAM skip all comparisons if the map did not change (guessing it is the same pointer or something like that) ?

Comparison of maps is optimised.

Pointers might or might not be compared as a shortcut, I don’t remember the details.

Anyway, first check I’m aware of is the maps size, then their keys, then values per key, while keys are sorted by term order.

2 Likes

Yes, BEAM does that optimization. If pointers are equal, they point to the same term and therefore the result of the comparison must be :true.

11 Likes

Good to know, thank you :slight_smile:

1 Like