Improve BlockFactory initialization performance

as expected, expanding data range unconditionally resulted in some performance issues ...
This commit is contained in:
Dylan K. Taylor
2022-06-27 15:37:05 +01:00
parent bedc9cf518
commit 0afb67be7d
75 changed files with 169 additions and 3 deletions

View File

@ -864,7 +864,11 @@ class BlockFactory{
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
//at some point we'll need to find a better way to do this
for($stateData = 0; $stateData < (1 << Block::INTERNAL_STATE_DATA_BITS); ++$stateData){
$bits = $block->getRequiredStateDataBits();
if($bits > Block::INTERNAL_STATE_DATA_BITS){
throw new \InvalidArgumentException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
}
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
$v = clone $block;
try{
$v->decodeStateData($stateData);