simplify bitwise operations to single statements

This commit is contained in:
Stephen Birarda 2013-02-18 16:32:39 -08:00
parent 8322c29093
commit e6a0f5cd6c

View file

@ -36,21 +36,12 @@ TreeNode *findOrCreateNode(int lengthInBits,
TreeNode *currentNode = &rootNode;
for (int i = 0; i < lengthInBits; i += 3) {
unsigned char octetA;
unsigned char octetB;
unsigned char octet;
/*
* @TODO Put those shifts into a nice single statement, leaving as is for now
*/
if (i%8 < 6) {
octetA = addressBytes[i/8] << i%8;
octet = octetA >> (5);
octet = addressBytes[i/8] << i%8 >> (5);
} else {
octetA = addressBytes[i/8] << i;
octetA = octetA >> (11 - i);
octetB = addressBytes[i/8 + 1] >> (11 - i + 2);
octet = octetA | octetB;
octet = (addressBytes[i/8] << i >> (11 - i)) | (addressBytes[i/8 + 1] >> (11 - i + 2));
}
if (currentNode->child[octet] == NULL) {