Browse Source

Push minor changes in the standard executor internals.

Daniele Alessandri 12 years ago
parent
commit
f2af247c63
1 changed files with 7 additions and 7 deletions
  1. 7 7
      lib/Predis/Pipeline/StandardExecutor.php

+ 7 - 7
lib/Predis/Pipeline/StandardExecutor.php

@@ -11,6 +11,7 @@
 
 namespace Predis\Pipeline;
 
+use Iterator;
 use SplQueue;
 use Predis\ResponseErrorInterface;
 use Predis\ResponseObjectInterface;
@@ -66,7 +67,7 @@ class StandardExecutor implements PipelineExecutorInterface
             return $this->onResponseError($connection, $response);
         }
 
-        if ($response instanceof \Iterator) {
+        if ($response instanceof Iterator) {
             return $command->parseResponse(iterator_to_array($response));
         }
 
@@ -97,23 +98,22 @@ class StandardExecutor implements PipelineExecutorInterface
      */
     public function execute(ConnectionInterface $connection, SplQueue $commands)
     {
-        $size = count($commands);
-        $values = array();
-
         $this->checkConnection($connection);
 
         foreach ($commands as $command) {
             $connection->writeCommand($command);
         }
 
-        for ($i = 0; $i < $size; $i++) {
+        $values = array();
+
+        while (!$commands->isEmpty()) {
             $command = $commands->dequeue();
             $response = $connection->readResponse($command);
 
             if ($response instanceof ResponseObjectInterface) {
-                $values[$i] = $this->onResponseObject($connection, $command, $response);
+                $values[] = $this->onResponseObject($connection, $command, $response);
             } else {
-                $values[$i] = $command->parseResponse($response);
+                $values[] = $command->parseResponse($response);
             }
         }