From e6a0f5cd6ceb0e1733a5d42b214c024edcb25a87 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 16:32:39 -0800 Subject: [PATCH] simplify bitwise operations to single statements --- space/src/main.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/space/src/main.cpp b/space/src/main.cpp index a617511d40..9a6033bdac 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -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) {