mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
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:
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user