1) Is it faster to get an array of 32 Boolean values on a 32-bit processor or get access to 32 bits in one word? (Suppose we want to check the value of the Nth element and use either a bitmask (the Nth bit is set) or an integer N as the index of the array.)
It seems to me that the array will be faster, because all common computer architectures initially work at the word level (32 bits, 64 bits, etc., are processed in parallel) and access to the bits of the subword requires additional work.
I know that different compilers will present things differently, but it seems that the underlying hardware architecture will dictate the answer. Or does the answer depend on the language and compiler?
A, 2) The response to speed is canceled if this array represents the state that I pass between the client and server? This question came to mind when reading the question " How to use a bit / bit operator to control the state of an object? "
PS Yes, I could write code to test it myself, but then the SO community wouldn’t be able to play!
Tom a source
share