소스 검색

Reduce method calls by one when creating a new connection in Predis\Client.

Daniele Alessandri 14 년 전
부모
커밋
6e6a28a9f0
1개의 변경된 파일11개의 추가작업 그리고 15개의 파일을 삭제
  1. 11 15
      lib/Predis/Client.php

+ 11 - 15
lib/Predis/Client.php

@@ -65,24 +65,20 @@ class Client {
         return $this->createConnection($parameters);
     }
 
-    private function createConnection($parameters) {
+    protected function createConnection($parameters) {
         $connection = $this->_connectionFactory->create($parameters);
-        $this->pushInitCommands($connection);
-        return $connection;
-    }
-
-    private function pushInitCommands(IConnectionSingle $connection) {
-        $params = $connection->getParameters();
-        if (isset($params->password)) {
-            $connection->pushInitCommand($this->createCommand(
-                'auth', array($params->password)
-            ));
+        $parameters = $connection->getParameters();
+        if (isset($parameters->password)) {
+            $connection->pushInitCommand(
+                $this->createCommand('auth', array($parameters->password))
+            );
         }
-        if (isset($params->database)) {
-            $connection->pushInitCommand($this->createCommand(
-                'select', array($params->database)
-            ));
+        if (isset($parameters->database)) {
+            $connection->pushInitCommand(
+                $this->createCommand('select', array($parameters->database))
+            );
         }
+        return $connection;
     }
 
     public function getProfile() {