Move around User::getEditCount() code.
authorPlatonides <platonides@gmail.com>
Mon, 26 Nov 2012 21:56:42 +0000 (22:56 +0100)
committerPlatonides <platonides@gmail.com>
Mon, 26 Nov 2012 21:56:42 +0000 (22:56 +0100)
It's simpler to do an early return and catch almost everything
in the profiling.

Change-Id: I2306c7b39d9808989f11d7d9d34db06c39d51820

includes/User.php

index 0aa613a..f55281e 100644 (file)
@@ -2454,30 +2454,29 @@ class User {
         * @return Int
         */
        public function getEditCount() {
-               if( $this->getId() ) {
-                       if ( !isset( $this->mEditCount ) ) {
-                               /* Populate the count, if it has not been populated yet */
-                               wfProfileIn( __METHOD__ );
-                               $dbr = wfGetDB( DB_SLAVE );
-                               // check if the user_editcount field has been initialized
-                               $count = $dbr->selectField(
-                                       'user', 'user_editcount',
-                                       array( 'user_id' => $this->mId ),
-                                       __METHOD__
-                               );
+               if ( !$this->getId() ) {
+                       return null;
+               }
 
-                               if( $count === null ) {
-                                       // it has not been initialized. do so.
-                                       $count = $this->initEditCount();
-                               }
-                               wfProfileOut( __METHOD__ );
-                               $this->mEditCount = intval( $count );
+               if ( !isset( $this->mEditCount ) ) {
+                       /* Populate the count, if it has not been populated yet */
+                       wfProfileIn( __METHOD__ );
+                       $dbr = wfGetDB( DB_SLAVE );
+                       // check if the user_editcount field has been initialized
+                       $count = $dbr->selectField(
+                               'user', 'user_editcount',
+                               array( 'user_id' => $this->mId ),
+                               __METHOD__
+                       );
+
+                       if( $count === null ) {
+                               // it has not been initialized. do so.
+                               $count = $this->initEditCount();
                        }
-                       return $this->mEditCount;
-               } else {
-                       /* nil */
-                       return null;
+                       $this->mEditCount = intval( $count );
+                       wfProfileOut( __METHOD__ );
                }
+               return $this->mEditCount;
        }
 
        /**