mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
BaseInventory: Don't keep calling getSize() over and over and over again
This commit is contained in:
parent
4b63a22f8c
commit
52bd042bde
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user