浏览代码

Minor speed optimizations.

Daniele Alessandri 14 年之前
父节点
当前提交
4e0e1908cd
共有 2 个文件被更改,包括 6 次插入6 次删除
  1. 1 1
      lib/Predis/Commands/Command.php
  2. 5 5
      lib/Predis/Network/ConnectionCluster.php

+ 1 - 1
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])) {

+ 5 - 5
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) {