From 5581a5e837500bd1bac519146496b962a27cd926 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 15 Aug 2011 13:16:10 +0000 Subject: [PATCH 1/1] Followup r94502: per CR, use two caching variables instead of an array indexed with true or false --- includes/GlobalFunctions.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 68d6865712..8e3e07c366 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -477,9 +477,10 @@ function wfUrlProtocols( $includeProtocolRelative = true ) { global $wgUrlProtocols; // Cache return values separately based on $includeProtocolRelative - static $retval = array( true => null, false => null ); - if ( !is_null( $retval[$includeProtocolRelative] ) ) { - return $retval[$includeProtocolRelative]; + static $withProtRel = null, $withoutProtRel = null; + $cachedValue = $includeProtocolRelative ? $withProtRel : $withoutProtRel; + if ( !is_null( $cachedValue ) ) { + return $cachedValue; } // Support old-style $wgUrlProtocols strings, for backwards compatibility @@ -493,15 +494,22 @@ function wfUrlProtocols( $includeProtocolRelative = true ) { } } - $retval[$includeProtocolRelative] = implode( '|', $protocols ); + $retval = implode( '|', $protocols ); } else { // Ignore $includeProtocolRelative in this case // This case exists for pre-1.6 compatibility, and we can safely assume // that '//' won't appear in a pre-1.6 config because protocol-relative // URLs weren't supported until 1.18 - $retval[$includeProtocolRelative] = $wgUrlProtocols; + $retval = $wgUrlProtocols; } - return $retval[$includeProtocolRelative]; + + // Cache return value + if ( $includeProtocolRelative ) { + $withProtRel = $retval; + } else { + $withoutProtRel = $retval; + } + return $retval; } /** -- 2.20.1