From 4e0e1908cdd771e15dccedabfe293063a6485fa9 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Wed, 23 Mar 2011 23:27:05 +0100 Subject: [PATCH] Minor speed optimizations. --- lib/Predis/Commands/Command.php | 2 +- lib/Predis/Network/ConnectionCluster.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Predis/Commands/Command.php b/lib/Predis/Commands/Command.php index c73a12cc..b5407370 100644 --- a/lib/Predis/Commands/Command.php +++ b/lib/Predis/Commands/Command.php @@ -27,7 +27,7 @@ abstract class Command implements ICommand { if (isset($this->_hash)) { return $this->_hash; } - if ($this->canBeHashed() === false) { + if (!$this->canBeHashed()) { return null; } if (!isset($this->_arguments[0])) { diff --git a/lib/Predis/Network/ConnectionCluster.php b/lib/Predis/Network/ConnectionCluster.php index 4cb25722..91167632 100644 --- a/lib/Predis/Network/ConnectionCluster.php +++ b/lib/Predis/Network/ConnectionCluster.php @@ -48,12 +48,12 @@ class ConnectionCluster implements IConnectionCluster, \IteratorAggregate { public function getConnection(ICommand $command) { $cmdHash = $command->getHash($this->_distributor); - if (isset($cmdHash) === false) { - throw new ClientException( - sprintf("Cannot send '%s' commands to a cluster of connections", $command->getId()) - ); + if (isset($cmdHash)) { + return $this->_distributor->get($cmdHash); } - return $this->_distributor->get($cmdHash); + throw new ClientException( + sprintf("Cannot send '%s' commands to a cluster of connections", $command->getId()) + ); } public function getConnectionById($id = null) {