mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +02:00
simplify bitwise operations to single statements
This commit is contained in:
parent
8322c29093
commit
e6a0f5cd6c
1 changed files with 2 additions and 11 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue