From: Stephan Bosch Date: Mon, 30 Sep 2019 08:30:25 +0000 (+0200) Subject: iputils.hh: NetmaskTree: Use for loops instead of while loops. X-Git-Tag: auth-4.3.0-beta2~20^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebb7e2159a6d99194d572c3de04afcc48a4dc591;p=thirdparty%2Fpdns.git iputils.hh: NetmaskTree: Use for loops instead of while loops. Makes using `continue' easier in later commit. --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 4e84f4c050..0048714b32 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -751,15 +751,14 @@ public: } else throw NetmaskException("invalid address family"); - int bits = 0; // we turn left on 0 and right on 1 - while(bits < key.getBits()) { + int bits = 0; + for(; bits < key.getBits(); bits++) { bool val = key.getBit(-1-bits); if (val) node = node->make_right(); else node = node->make_left(); - bits++; } // only create node if not yet assigned @@ -809,7 +808,7 @@ public: node_type *ret = nullptr; int bits = 0; - while(bits < max_bits) { + for(; bits < max_bits; bits++) { // ...we keep track of last non-empty node if (node->node) ret = node->node.get(); bool val = value.getBit(-1-bits); @@ -822,7 +821,6 @@ public: if (node->left) node = node->left.get(); else break; } - bits++; } // needed if we did not find one in loop if (node->node) ret = node->node.get(); @@ -845,14 +843,13 @@ public: if (node == nullptr) return; int bits = 0; - while(node && bits < key.getBits()) { + for(; node && bits < key.getBits(); bits++) { bool val = key.getBit(-1-bits); if (val) { node = node->right.get(); } else { node = node->left.get(); } - bits++; } if (node) { _nodes.erase(node->node.get());