X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FINet%2FINet6Address.ct;h=1ee2a0295db0c1a7cecf43e2af8c20c281d49971;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=fa6374522b9d4558b92444d68a061b62c5661a0c;hpb=1d2cb1ddff65fbd747b4a8359051b9e0ee7ab255;p=senf.git diff --git a/Socket/Protocols/INet/INet6Address.ct b/Socket/Protocols/INet/INet6Address.ct index fa63745..1ee2a02 100644 --- a/Socket/Protocols/INet/INet6Address.ct +++ b/Socket/Protocols/INet/INet6Address.ct @@ -51,17 +51,12 @@ template prefix_ void senf::detail::apply_mask(unsigned bits, ForwardIterator b, ForwardIterator e, Function fn) { - for(; b != e; ++b) { - boost::uint8_t mask (0); - if (bits > 8) { - mask = 0xFFu; - bits -= 8; - } else if (bits > 0) { - mask = ~ low_bits_mask(8-bits); - bits = 0; - } - fn(*b,mask); - } + for(; bits>8 && b != e; bits -= 8, ++b) + fn(*b, boost::lambda::make_const(0xFFu)); + if (bits > 0 && b != e) + fn( *(b++), boost::lambda::make_const(~ low_bits_mask(8-bits))); + for(; b != e; ++b) + fn(*b, boost::lambda::make_const(0u)); } template @@ -69,18 +64,15 @@ prefix_ ForwardIterator1 senf::detail::find_if_mask(unsigned bits, ForwardIterat ForwardIterator1 e1, ForwardIterator2 b2, Function fn) { - for(; b1 != e1; ++b1, ++b2) { - boost::uint8_t mask (0); - if (bits > 8) { - mask = 0xFFu; - bits -= 8; - } else if (bits > 0) { - mask = ~ low_bits_mask(8-bits); - bits = 0; - } - if (fn(*b1,*b2,mask)) + for(; bits>8 && b1 != e1; bits -= 8, ++b1, ++b2) + if (fn(*b1, *b2, boost::lambda::make_const(0xFFu))) + return b1; + if (bits > 0 && b1 != e1) + if (fn( *(b1++), *(b2++), boost::lambda::make_const(~ low_bits_mask(8-bits)))) + return b1; + for(; b1 != e1; ++b1, ++b2) + if (fn(*b1, *b2, boost::lambda::make_const(0u))) return b1; - } return e1; }