浏览代码

Minor change (mostly micro-optimization).

Daniele Alessandri 13 年之前
父节点
当前提交
69d4c013f7
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 3 1
      lib/Predis/Cluster/PredisClusterHashStrategy.php
  2. 3 1
      lib/Predis/Cluster/RedisClusterHashStrategy.php

+ 3 - 1
lib/Predis/Cluster/PredisClusterHashStrategy.php

@@ -311,7 +311,9 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface
         $hash = $command->getHash();
 
         if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) {
-            if ($key = call_user_func($this->commands[$cmdID], $command)) {
+            $key = call_user_func($this->commands[$cmdID], $command);
+
+            if (isset($key)) {
                 $hash = $this->getKeyHash($key);
                 $command->setHash($hash);
             }

+ 3 - 1
lib/Predis/Cluster/RedisClusterHashStrategy.php

@@ -263,7 +263,9 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface
         $hash = $command->getHash();
 
         if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) {
-            if (null !== $key = call_user_func($this->commands[$cmdID], $command)) {
+            $key = call_user_func($this->commands[$cmdID], $command);
+
+            if (isset($key)) {
                 $hash = $this->hashGenerator->hash($key);
                 $command->setHash($hash);
             }