The question here is whether the actual implementation of your coding would be faster. Generally, a C-Compiler using a set of chars creates an array of 32 bytes and sets each of the bits corresponding to the char in the set to true.
Depending on the processor, the relative address of the array is loaded and then a bittst function calculates the offset to the appropriate bit and does a test on it. There is a memory load, an offset add, a memory access, and then the test. Then a decision jump is done.
The implementation of the array scheme you propose does something similar, except that there is an absolute memory add calculation involved.
So the question is whether, on an individual compiler implementation (depending on the processor as well), it takes less time for the internal processor to do the offset calculation or the individual processor to do the memory add calculation. The compiler creates the array in both cases on initialization, or you can create a blank array and fill it on the go.
When dealing with repeated uses of such arrays, speed is a consideration.
Depending on the processor, the relative address of the array is loaded and then a bittst function calculates the offset to the appropriate bit and does a test on it. There is a memory load, an offset add, a memory access, and then the test. Then a decision jump is done.
The implementation of the array scheme you propose does something similar, except that there is an absolute memory add calculation involved.
So the question is whether, on an individual compiler implementation (depending on the processor as well), it takes less time for the internal processor to do the offset calculation or the individual processor to do the memory add calculation. The compiler creates the array in both cases on initialization, or you can create a blank array and fill it on the go.
When dealing with repeated uses of such arrays, speed is a consideration.
Thanks for the suggestion.
Tim.
Tim.