Эх сурвалжийг харах

Avoid allocating an iterator to traverse the arguments list of a command.

Daniele Alessandri 14 жил өмнө
parent
commit
a1db042d17
1 өөрчлөгдсөн 2 нэмэгдсэн , 1 устгасан
  1. 2 1
      lib/Predis.php

+ 2 - 1
lib/Predis.php

@@ -424,7 +424,8 @@ abstract class Command implements ICommand {
         $reqlen  = count($arguments) + 1;
 
         $buffer = "*{$reqlen}{$newline}\${$cmdlen}{$newline}{$command}{$newline}";
-        foreach ($arguments as $argument) {
+        for ($i = 0; $i < $reqlen - 1;  $i++) {
+            $argument = $arguments[$i];
             $arglen  = strlen($argument);
             $buffer .= "\${$arglen}{$newline}{$argument}{$newline}";
         }