I'm working with limited memory and need to quickly access a single bit in an array char s[80][10], which effectively gives me an 80x80 array with each index only being a single bit.
This is how I'm currently setting, clearing, and checking individual bits:
s[(row)][(col) >> 3] |= (0x80 >> ((col) & 0x07)); //set bit at s[row][col]
s[(row)][(col) >> 3] &= ~(0x80 >> ((col) & 0x07)); //clear bit at s[row][col]
int bit = (s[row][(col) >> 3] & (0x80 >> ((col) & 0x07)) ? 1 : 0); // read bit at s[row][col] into int bit
Is there some simplification to make these perform faster?
Thanks!