mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +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;
|
TreeNode *currentNode = &rootNode;
|
||||||
|
|
||||||
for (int i = 0; i < lengthInBits; i += 3) {
|
for (int i = 0; i < lengthInBits; i += 3) {
|
||||||
unsigned char octetA;
|
|
||||||
unsigned char octetB;
|
|
||||||
unsigned char octet;
|
unsigned char octet;
|
||||||
|
|
||||||
/*
|
|
||||||
* @TODO Put those shifts into a nice single statement, leaving as is for now
|
|
||||||
*/
|
|
||||||
if (i%8 < 6) {
|
if (i%8 < 6) {
|
||||||
octetA = addressBytes[i/8] << i%8;
|
octet = addressBytes[i/8] << i%8 >> (5);
|
||||||
octet = octetA >> (5);
|
|
||||||
} else {
|
} else {
|
||||||
octetA = addressBytes[i/8] << i;
|
octet = (addressBytes[i/8] << i >> (11 - i)) | (addressBytes[i/8 + 1] >> (11 - i + 2));
|
||||||
octetA = octetA >> (11 - i);
|
|
||||||
octetB = addressBytes[i/8 + 1] >> (11 - i + 2);
|
|
||||||
octet = octetA | octetB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentNode->child[octet] == NULL) {
|
if (currentNode->child[octet] == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue