From f8c3d4bfb41b9d4267c98a7c078e0f1a6beebfdf Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 22 Nov 2004 10:05:11 +0000 Subject: [PATCH] Inner loop optimization: reverse order of conditions for language variant link check, so the condition short-circuits correctly and we can skip the expensive per-link lookup. --- includes/Parser.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index d25a27b9d6..3a17300d6b 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1167,8 +1167,8 @@ class Parser # Loop for each link for ($k = 0; isset( $a[$k] ); $k++) { $line = $a[$k]; - wfProfileIn( $fname.'-prefixhandling' ); if ( $useLinkPrefixExtension ) { + wfProfileIn( $fname.'-prefixhandling' ); if ( preg_match( $e2, $s, $m ) ) { $prefix = $m[2]; $s = $m[1]; @@ -1180,8 +1180,8 @@ class Parser $prefix = $first_prefix; $first_prefix = false; } + wfProfileOut( $fname.'-prefixhandling' ); } - wfProfileOut( $fname.'-prefixhandling' ); $might_be_img = false; @@ -1225,8 +1225,8 @@ class Parser #check other language variants of the link #if the article does not exist - if( $nt->getArticleID() == 0 - && $checkVariantLink ) { + if( $checkVariantLink + && $nt->getArticleID() == 0 ) { $wgContLang->findVariantLink($link, $nt); } @@ -3137,7 +3137,6 @@ class ParserOptions # Get user options function initialiseFromUser( &$userInput ) { global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; - $fname = 'ParserOptions::initialiseFromUser'; wfProfileIn( $fname ); if ( !$userInput ) { -- 2.20.1