1
0

Add ProtocolBlockTypePalette (#4391)

This commit is contained in:
E14
2019-09-22 22:57:54 +02:00
committed by Mattes D
parent 70d0b46b60
commit d1c95742dd
15 changed files with 815 additions and 0 deletions

View File

@@ -83,6 +83,52 @@ BlockState::BlockState(const BlockState & aCopyFrom, const std::map<AString, ASt
bool BlockState::operator <(const BlockState & aOther) const
{
// Fast-return this using checksum
if (mChecksum != aOther.mChecksum)
{
return (mChecksum < aOther.mChecksum);
}
// Can fast-return this due to how comparison works
if (mState.size() != aOther.mState.size())
{
return (mState.size() < aOther.mState.size());
}
auto itA = mState.begin();
auto itOther = aOther.mState.begin();
// don't need to check itOther, size checks above ensure size(A) == size(O)
while (itA != mState.end())
{
{
const auto cmp = itA->first.compare(itOther->first);
if (cmp != 0)
{
return (cmp < 0);
}
}
{
const auto cmp = itA->second.compare(itOther->second);
if (cmp != 0)
{
return (cmp < 0);
}
}
++itA;
++itOther;
}
return false;
}
bool BlockState::operator ==(const BlockState & aOther) const
{
// Fast-fail if the checksums differ or differrent counts: