jenkins-bot has submitted this change and it was merged.

Change subject: Factor out some code to a separate function for better profiling
......................................................................


Factor out some code to a separate function for better profiling

Need to rule out the reason for unexpectedly slow profiling results for
{{#coordinates}} in production - if the new function takes the majority
of time, it's just because people feed complex wikitext into it.

Change-Id: Ibb5312973316b0d8348c2bb2cfa9fcb6702250e7
---
M CoordinatesParserFunction.php
1 file changed, 24 insertions(+), 13 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CoordinatesParserFunction.php b/CoordinatesParserFunction.php
index 4ea8969..214e257 100644
--- a/CoordinatesParserFunction.php
+++ b/CoordinatesParserFunction.php
@@ -46,18 +46,8 @@
 
                $this->unnamed = array();
                $this->named = array();
-               $first = trim( $frame->expand( array_shift( $args ) ) );
-               $this->addArg( $first );
-               foreach ( $args as $arg ) {
-                       $bits = $arg->splitArg();
-                       $value = trim( $frame->expand( $bits['value'] ) );
-                       if ( $bits['index'] === '' ) {
-                               $this->named[trim( $frame->expand( 
$bits['name'] ) )] = $value;
-                       } else {
-                               $this->addArg( $value );
-                       }
-               }
-               $this->parseTagArgs();
+               $this->parseArgs( $frame, $args );
+               $this->processArgs();
                $status = GeoData::parseCoordinates( $this->unnamed, 
$this->named['globe'] );
                if ( $status->isGood() ) {
                        $coord = $status->value;
@@ -80,6 +70,27 @@
                }
                wfProfileOut( __METHOD__ );
                return array( "<span class=\"error\">{$errorText}</span>", 
'noparse' => false );
+       }
+
+       /**
+        * Parses parser function input
+        * @param PPFrame $frame
+        * @param Array $args
+        */
+       private function parseArgs( $frame, $args ) {
+               wfProfileIn( __METHOD__ );
+               $first = trim( $frame->expand( array_shift( $args ) ) );
+               $this->addArg( $first );
+               foreach ( $args as $arg ) {
+                       $bits = $arg->splitArg();
+                       $value = trim( $frame->expand( $bits['value'] ) );
+                       if ( $bits['index'] === '' ) {
+                               $this->named[trim( $frame->expand( 
$bits['name'] ) )] = $value;
+                       } else {
+                               $this->addArg( $value );
+                       }
+               }
+               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -130,7 +141,7 @@
        /**
         * Merges parameters with decoded GeoHack data, sets default globe
         */
-       private function parseTagArgs() {
+       private function processArgs() {
                global $wgDefaultGlobe, $wgContLang;
                // fear not of overwriting the stuff we've just received from 
the geohack param, it has minimum precedence
                if ( isset( $this->named['geohack'] ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/94683
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb5312973316b0d8348c2bb2cfa9fcb6702250e7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to