BaseInventory: Don't keep calling getSize() over and over and over again

This commit is contained in:
Dylan K. Taylor 2017-09-27 11:24:16 +01:00
parent 4b63a22f8c
commit 52bd042bde

View File

@ -219,7 +219,7 @@ abstract class BaseInventory implements Inventory{
$item = clone $item;
$checkDamage = !$item->hasAnyDamageValue();
$checkTags = $item->hasCompoundTag();
for($i = 0; $i < $this->getSize(); ++$i){
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
$slot = $this->getItem($i);
if($item->equals($slot, $checkDamage, $checkTags)){
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
@ -249,7 +249,7 @@ abstract class BaseInventory implements Inventory{
$emptySlots = [];
for($i = 0; $i < $this->getSize(); ++$i){
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
$item = $this->getItem($i);
if($item->isNull()){
$emptySlots[] = $i;
@ -304,7 +304,7 @@ abstract class BaseInventory implements Inventory{
}
}
for($i = 0; $i < $this->getSize(); ++$i){
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
$item = $this->getItem($i);
if($item->isNull()){
continue;