mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 00:25:04 +00:00
BaseInventory: Don't keep calling getSize() over and over and over again
This commit is contained in:
@ -219,7 +219,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
$item = clone $item;
|
$item = clone $item;
|
||||||
$checkDamage = !$item->hasAnyDamageValue();
|
$checkDamage = !$item->hasAnyDamageValue();
|
||||||
$checkTags = $item->hasCompoundTag();
|
$checkTags = $item->hasCompoundTag();
|
||||||
for($i = 0; $i < $this->getSize(); ++$i){
|
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||||
$slot = $this->getItem($i);
|
$slot = $this->getItem($i);
|
||||||
if($item->equals($slot, $checkDamage, $checkTags)){
|
if($item->equals($slot, $checkDamage, $checkTags)){
|
||||||
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
|
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
|
||||||
@ -249,7 +249,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
|
|
||||||
$emptySlots = [];
|
$emptySlots = [];
|
||||||
|
|
||||||
for($i = 0; $i < $this->getSize(); ++$i){
|
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||||
$item = $this->getItem($i);
|
$item = $this->getItem($i);
|
||||||
if($item->isNull()){
|
if($item->isNull()){
|
||||||
$emptySlots[] = $i;
|
$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);
|
$item = $this->getItem($i);
|
||||||
if($item->isNull()){
|
if($item->isNull()){
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user