r105069 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105068‎ | r105069 | r105070 >
Date:14:56, 3 December 2011
Author:danwe
Status:deferred
Tags:
Comment:
'#arrayprint' performance increased in case no subject is given
Modified paths:
  • /trunk/extensions/Arrays/Arrays.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Arrays/Arrays.php
@@ -11,6 +11,7 @@
1212 * @ingroup Arrays
1313 *
1414 * @licence MIT License
 15+ * @version: 2.0 alpha
1516 *
1617 * @author Li Ding < lidingpku@gmail.com >
1718 * @author Jie Bao
@@ -288,8 +289,8 @@
289290 * in $subject before $subject is being parsed. So any template or argument influence in the patterns wouldn't make any
290291 * sense in any sane scenario.
291292 */
292 - $search = isset( $args[2] ) ? trim( $frame->expand( $args[2], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES ) ) : '@@@@';
293 - $subject = isset( $args[3] ) ? trim( $frame->expand( $args[3], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES ) ) : '@@@@';
 293+ $search = isset( $args[2] ) ? trim( $frame->expand( $args[2], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES ) ) : null;
 294+ $subject = isset( $args[3] ) ? trim( $frame->expand( $args[3], PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES ) ) : null;
294295 // options array:
295296 $options = isset( $args[4] )
296297 ? self::parse_options( $frame->expand( $args[4] ) )
@@ -308,6 +309,13 @@
309310 return "undefined array: $arrayId";
310311 }
311312 }
 313+
 314+ // if there is no subject, there is no point in expanding. Faster!
 315+ if( !$egArraysCompatibilityMode && $subject === null ) {
 316+ // NO COMPATIBILITY-MODE
 317+ // we can ignore options here, since if subject is null, options won't be set as well!
 318+ return trim( implode( $delimiter, $array ) );
 319+ }
312320
313321 $rendered_values = array();
314322

Follow-up revisions

RevisionCommit summaryAuthorDate
r105231Fixes some bug introduced in r105069, where '#arrayprint' was broken in compa...danwe21:56, 5 December 2011

Status & tagging log