Adopted ceiling division in mbits formula
So now:
(block_size)
mbits = nlog2(----------) = nlog2(block_size) - 3
( 8 )
Instead of:
( (block_size))
mbits = nlog2(floor(----------)) = nlog2(block_size & ~0x7) - 3
( ( 8 ))
This makes the post-log - 3 formula simpler, which we probably want to
prefer as it avoids a division. And ceiling is arguably more intuitive
corner case behavior.
This may seem like a minor detail, but because mbits is purely
block_size derived and not configurable, any quirks here will become
a permanent compatibility requirement.
And hey, it saves a couple bytes (I'm not really sure why, the division
should've been optimized to a shift):
code stack ctx
before: 35528 2440 636
after: 35520 (-0.0%) 2440 (+0.0%) 636 (+0.0%)
This commit is contained in:
+1
-1
@@ -1633,7 +1633,7 @@ class Mtree:
|
||||
def mbits_(block_size):
|
||||
if isinstance(block_size, Bd):
|
||||
block_size = block_size.block_size
|
||||
return mt.ceil(mt.log2(block_size // 8))
|
||||
return mt.ceil(mt.log2(block_size)) - 3
|
||||
|
||||
# convenience function for creating mbits-dependent mids
|
||||
def mid(self, mbid, mrid=None):
|
||||
|
||||
Reference in New Issue
Block a user