-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
I was very surprised to see that BitArray uses bool[] as an underlying type. If you didn't know, the bool type in C# actually allocates an entire byte of memory because that is the minimum addressable size used by the CLR. You waste 7 bits for every bool. See https://stackoverflow.com/questions/2308034/primitive-boolean-size-in-c-sharp/2308052
I see @LorenzoLotti was the original contributor so I'm tagging them.
A maximum performance gain would be to use byte[], int[], or long[] as the underlying data type and then use bitwise operations to get the bit value you actually want.
This improvement seems minor compared to the effort to implement, but could maximize memory usage for very large data sets.