Remove function calls from for loop test part
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Wed, 20 Nov 2013 10:27:05 +0000 (11:27 +0100)
committerSiebrand <siebrand@wikimedia.org>
Thu, 21 Nov 2013 04:44:49 +0000 (04:44 +0000)
Change-Id: If1f8996854889b526fef96cd29a153e0b36e9133

includes/db/LoadBalancer.php

index 011c083..bfa1add 100644 (file)
@@ -372,7 +372,8 @@ class LoadBalancer {
        public function waitForAll( $pos ) {
                wfProfileIn( __METHOD__ );
                $this->mWaitForPos = $pos;
-               for ( $i = 1; $i < count( $this->mServers ); $i++ ) {
+               $serverCount = count( $this->mServers );
+               for ( $i = 1; $i < $serverCount; $i++ ) {
                        if ( $this->mLoads[$i] > 0 ) {
                                $this->doWait( $i, true );
                        }
@@ -850,7 +851,8 @@ class LoadBalancer {
                # master (however unlikely that may be), then we can fetch the position from the slave.
                $masterConn = $this->getAnyOpenConnection( 0 );
                if ( !$masterConn ) {
-                       for ( $i = 1; $i < count( $this->mServers ); $i++ ) {
+                       $serverCount = count( $this->mServers );
+                       for ( $i = 1; $i < $serverCount; $i++ ) {
                                $conn = $this->getAnyOpenConnection( $i );
                                if ( $conn ) {
                                        wfDebug( "Master pos fetched from slave\n" );