mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
dead code removal
This commit is contained in:
parent
3914964a35
commit
3f32cffc40
1 changed files with 0 additions and 84 deletions
|
@ -116,90 +116,6 @@ public:
|
||||||
ZT_INLINE bool operator>=(const Address &a) const noexcept { return _a >= a._a; }
|
ZT_INLINE bool operator>=(const Address &a) const noexcept { return _a >= a._a; }
|
||||||
ZT_INLINE bool operator<=(const Address &a) const noexcept { return _a <= a._a; }
|
ZT_INLINE bool operator<=(const Address &a) const noexcept { return _a <= a._a; }
|
||||||
|
|
||||||
#if 0
|
|
||||||
/**
|
|
||||||
* Create a list of the first N bits of a list of unique addresses with N as the minimum unique size
|
|
||||||
*
|
|
||||||
* The list is stored in a space-efficient packed bit format.
|
|
||||||
*
|
|
||||||
* @param start Starting Address iterator/pointer
|
|
||||||
* @param end Ending Address iterator/pointer
|
|
||||||
* @param list Pointer to location to write list
|
|
||||||
* @param listCapacityBytes Number of bytes available for list
|
|
||||||
* @return Number of bytes written or -1 on overflow or other error
|
|
||||||
* @tparam I Input iterator type
|
|
||||||
*/
|
|
||||||
template<typename I>
|
|
||||||
static inline int createMinPrefixList(I start,I end,uint8_t *list,const int listCapacityBytes)
|
|
||||||
{
|
|
||||||
std::vector<Address> sortedAddrs(start,end);
|
|
||||||
if (sortedAddrs.empty())
|
|
||||||
return 0;
|
|
||||||
if (listCapacityBytes == 0)
|
|
||||||
return -1;
|
|
||||||
std::sort(sortedAddrs.begin(),sortedAddrs.end());
|
|
||||||
|
|
||||||
unsigned int bits = (unsigned int)fmaxf(log2f((float)(sortedAddrs.size() * 2)),3.0F);
|
|
||||||
uint64_t mask;
|
|
||||||
try_additional_bits: {
|
|
||||||
mask = 0xffffffffffffffffULL >> (64 - bits);
|
|
||||||
std::vector<Address>::iterator a(sortedAddrs.begin());
|
|
||||||
uint64_t aa = *(a++) & mask;
|
|
||||||
aa |= (uint64_t)(aa == 0);
|
|
||||||
uint64_t lastMaskedAddress = aa;
|
|
||||||
while (a != sortedAddrs.end()) {
|
|
||||||
aa = *(a++) & mask;
|
|
||||||
aa |= (uint64_t)(aa == 0);
|
|
||||||
if (aa == lastMaskedAddress) {
|
|
||||||
++bits;
|
|
||||||
goto try_additional_bits;
|
|
||||||
}
|
|
||||||
lastMaskedAddress = aa;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int l = 0;
|
|
||||||
unsigned int bitPtr = 0;
|
|
||||||
for(I a(start);a!=end;) {
|
|
||||||
uint64_t aa = *(a++) & mask;
|
|
||||||
aa |= (uint64_t)(aa == 0);
|
|
||||||
unsigned int br = bits;
|
|
||||||
if (bitPtr > 0) {
|
|
||||||
unsigned int w = 8 - bitPtr;
|
|
||||||
if (w > br) w = br;
|
|
||||||
list[l] = (list[l] << w) | (((uint8_t)aa) & (0xff >> (8 - w)));
|
|
||||||
bitPtr += w;
|
|
||||||
if (bitPtr == 8) {
|
|
||||||
bitPtr = 0;
|
|
||||||
if (l >= listCapacityBytes)
|
|
||||||
return -1;
|
|
||||||
++l;
|
|
||||||
}
|
|
||||||
aa >>= w;
|
|
||||||
br -= w;
|
|
||||||
}
|
|
||||||
while (br >= 8) {
|
|
||||||
if (l >= listCapacityBytes)
|
|
||||||
return -1;
|
|
||||||
list[l++] = (uint8_t)aa;
|
|
||||||
br -= 8;
|
|
||||||
aa >>= 8;
|
|
||||||
}
|
|
||||||
if (br > 0) {
|
|
||||||
list[l] = (uint8_t)aa;
|
|
||||||
bitPtr = br;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bitPtr > 0) {
|
|
||||||
if (l >= listCapacityBytes)
|
|
||||||
return -1;
|
|
||||||
++l;
|
|
||||||
}
|
|
||||||
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t _a;
|
uint64_t _a;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue