From 86f3b257a72afa819a99628d95368d0bf83ef2e9 Mon Sep 17 00:00:00 2001 From: Muqsit Rayyan Date: Tue, 30 May 2017 15:27:47 +0300 Subject: [PATCH] Remove unneeded foreach loop in Human::getDrops() (#941) * Remove unneeded foreach loop in Human::getDrops() * Use array_values() for backwards compatibility. --- src/pocketmine/entity/Human.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 9797ead87..51ab0e819 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -425,14 +425,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } public function getDrops(){ - $drops = []; - if($this->inventory !== null){ - foreach($this->inventory->getContents() as $item){ - $drops[] = $item; - } - } - - return $drops; + return $this->inventory !== null ? array_values($this->inventory->getContents()) : []; } public function saveNBT(){