SimpleInventory: improved performance of setContents()

avoid the overhead incurred by clear() and setItem(), because in internalSetContents(), we already have no listeners or viewers to talk to anyway, so this is just spamming shit into /dev/null.
This commit is contained in:
Dylan K. Taylor
2021-12-31 18:32:19 +00:00
parent 38b6b39cb3
commit 72f2c794ab

View File

@ -71,10 +71,10 @@ class SimpleInventory extends BaseInventory{
protected function internalSetContents(array $items) : void{
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
if(!isset($items[$i])){
$this->clear($i);
if(!isset($items[$i]) || $items[$i]->isNull()){
$this->slots[$i] = null;
}else{
$this->setItem($i, $items[$i]);
$this->slots[$i] = clone $items[$i];
}
}
}