|
|
|
|
|
by masklinn
1990 days ago
|
|
The problem of doing that is twofold: * each key now has 3 possible states (true, false, and unset) rather than two * a bool takes 1 byte to store (which may get more problematic due to alignment, I've never checked what the memory layout of go's map is so I don't know how much of a concern it is there) An empty struct fixes these issues: a key being present means the item is in the set, and an empty struct is zero-sized. edit: apparently go maps are laid out as buckets of 8 entries with all the keys followed by all the values, so there's no waste due to padding at least. |
|