r94511 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94510‎ | r94511 | r94512 >
Date:13:16, 15 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r94502: per CR, use two caching variables instead of an array indexed with true or false
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -477,9 +477,10 @@
478478 global $wgUrlProtocols;
479479
480480 // Cache return values separately based on $includeProtocolRelative
481 - static $retval = array( true => null, false => null );
482 - if ( !is_null( $retval[$includeProtocolRelative] ) ) {
483 - return $retval[$includeProtocolRelative];
 481+ static $withProtRel = null, $withoutProtRel = null;
 482+ $cachedValue = $includeProtocolRelative ? $withProtRel : $withoutProtRel;
 483+ if ( !is_null( $cachedValue ) ) {
 484+ return $cachedValue;
484485 }
485486
486487 // Support old-style $wgUrlProtocols strings, for backwards compatibility
@@ -493,15 +494,22 @@
494495 }
495496 }
496497
497 - $retval[$includeProtocolRelative] = implode( '|', $protocols );
 498+ $retval = implode( '|', $protocols );
498499 } else {
499500 // Ignore $includeProtocolRelative in this case
500501 // This case exists for pre-1.6 compatibility, and we can safely assume
501502 // that '//' won't appear in a pre-1.6 config because protocol-relative
502503 // URLs weren't supported until 1.18
503 - $retval[$includeProtocolRelative] = $wgUrlProtocols;
 504+ $retval = $wgUrlProtocols;
504505 }
505 - return $retval[$includeProtocolRelative];
 506+
 507+ // Cache return value
 508+ if ( $includeProtocolRelative ) {
 509+ $withProtRel = $retval;
 510+ } else {
 511+ $withoutProtRel = $retval;
 512+ }
 513+ return $retval;
506514 }
507515
508516 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r945621.17wmf1: MFT r93711, r94346, r94369, r94376, r94404, r94502, r94509, r94511catrope20:30, 15 August 2011
r964701.17wmf1: MFT r92962, r93062, r93093, r93385, r93468, r93473, r94350, r94502,...catrope19:07, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94502(bug 30269) Strings like foobar//barfoo are linked to become foobar[//barfoo]...catrope12:20, 15 August 2011

Status & tagging log