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

Preallocate an empty array for empty command arguments.

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

+ 6 - 3
lib/Predis.php

@@ -417,7 +417,8 @@ class Protocol {
 }
 
 abstract class Command {
-    private $_arguments, $_hash;
+    private $_hash;
+    private $_arguments = array();
 
     public abstract function getCommandId();
 
@@ -469,11 +470,13 @@ abstract class Command {
     }
 
     public function getArguments() {
-        return isset($this->_arguments) ? $this->_arguments : array();
+        return $this->_arguments;
     }
 
     public function getArgument($index = 0) {
-        return isset($this->_arguments[$index]) ? $this->_arguments[$index] : null;
+        if (isset($this->_arguments[$index]) === true) {
+            return $this->_arguments[$index];
+        }
     }
 
     public function parseResponse($data) {