Merge pull request #10144 from mpimenov/z-order

[geometry] A simplification of FromInt64ZOrder.
This commit is contained in:
cc-engineering 2018-12-24 18:20:13 +03:00 committed by GitHub
commit bb9a4248a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -269,13 +269,12 @@ public:
ASSERT_LESS_OR_EQUAL(static_cast<uint64_t>(v), TreeSizeForDepth(depth), ());
uint64_t bits = 0;
int level = 0;
--v;
while (v > 0)
while (v > 1)
{
bits <<= 2;
++level;
int64_t subtreeSize = static_cast<int64_t>(TreeSizeForDepth(depth - level));
for (--v; v >= subtreeSize; v -= subtreeSize)
uint64_t const subtreeSize = TreeSizeForDepth(depth - level);
for (--v; v > subtreeSize; v -= subtreeSize)
++bits;
}
return CellId(bits, level);