From d26fcf7dee9dadf451f25067124044ded6a86544 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 6 Feb 2020 15:58:27 +0000 Subject: [PATCH] Removed useless casts() from min/max calls --- src/pocketmine/MemoryManager.php | 2 +- src/pocketmine/Server.php | 2 +- src/pocketmine/command/defaults/HelpCommand.php | 2 +- src/pocketmine/entity/Human.php | 2 +- src/pocketmine/entity/utils/ExperienceUtils.php | 2 +- src/pocketmine/network/rcon/RCON.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index 63d1db83c..20ec90997 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -181,7 +181,7 @@ class MemoryManager{ * Returns the allowed chunk radius based on the current memory usage. */ public function getViewDistance(int $distance) : int{ - return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? (int) min($this->lowMemChunkRadiusOverride, $distance) : $distance; + return ($this->lowMemory and $this->lowMemChunkRadiusOverride > 0) ? min($this->lowMemChunkRadiusOverride, $distance) : $distance; } /** diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index fdd3f9f81..f3c399ad3 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1388,7 +1388,7 @@ class Server{ $poolSize = max(1, (int) $poolSize); } - $this->asyncPool = new AsyncPool($this, $poolSize, (int) max(-1, (int) $this->getProperty("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger); + $this->asyncPool = new AsyncPool($this, $poolSize, max(-1, (int) $this->getProperty("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger); if($this->getProperty("network.batch-threshold", 256) >= 0){ Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256); diff --git a/src/pocketmine/command/defaults/HelpCommand.php b/src/pocketmine/command/defaults/HelpCommand.php index c4bf73f44..5e761d180 100644 --- a/src/pocketmine/command/defaults/HelpCommand.php +++ b/src/pocketmine/command/defaults/HelpCommand.php @@ -82,7 +82,7 @@ class HelpCommand extends VanillaCommand{ } ksort($commands, SORT_NATURAL | SORT_FLAG_CASE); $commands = array_chunk($commands, $pageHeight); - $pageNumber = (int) min(count($commands), $pageNumber); + $pageNumber = min(count($commands), $pageNumber); if($pageNumber < 1){ $pageNumber = 1; } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 130dfec8d..9049024f6 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -524,7 +524,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ public function getXpDropAmount() : int{ //this causes some XP to be lost on death when above level 1 (by design), dropping at most enough points for //about 7.5 levels of XP. - return (int) min(100, 7 * $this->getXpLevel()); + return min(100, 7 * $this->getXpLevel()); } /** diff --git a/src/pocketmine/entity/utils/ExperienceUtils.php b/src/pocketmine/entity/utils/ExperienceUtils.php index 3e4f4f74e..9b387b397 100644 --- a/src/pocketmine/entity/utils/ExperienceUtils.php +++ b/src/pocketmine/entity/utils/ExperienceUtils.php @@ -75,6 +75,6 @@ abstract class ExperienceUtils{ $x = Math::solveQuadratic($a, $b, $c - $xp); - return (float) max($x); //we're only interested in the positive solution + return max($x); //we're only interested in the positive solution } } diff --git a/src/pocketmine/network/rcon/RCON.php b/src/pocketmine/network/rcon/RCON.php index 8da98c165..617f2ea9c 100644 --- a/src/pocketmine/network/rcon/RCON.php +++ b/src/pocketmine/network/rcon/RCON.php @@ -94,7 +94,7 @@ class RCON{ $this->server->getTickSleeper()->addNotifier($notifier, function() : void{ $this->check(); }); - $this->instance = new RCONInstance($this->socket, $password, (int) max(1, $maxClients), $this->server->getLogger(), $this->ipcThreadSocket, $notifier); + $this->instance = new RCONInstance($this->socket, $password, max(1, $maxClients), $this->server->getLogger(), $this->ipcThreadSocket, $notifier); socket_getsockname($this->socket, $addr, $port); $this->server->getLogger()->info("RCON running on $addr:$port");