r38104 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38103‎ | r38104 | r38105 >
Date:18:14, 27 July 2008
Author:simetrical
Status:old
Tags:
Comment:
Indeed, this is a ResultWrapper object, so we can iterate over it: no ugly while loops. In fact, we don't even have to bother creating the array. A few quick tests show >100 KB peak memory usage drop even on a quite small RC, a couple dozen items.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -96,22 +96,19 @@
9797 $rows = array();
9898 $batch = new LinkBatch;
9999 $conds = $this->buildMainQueryConds( $opts );
100 - $res = $this->doMainQuery( $conds, $opts );
101 - if( $res === false ){
 100+ $rows = $this->doMainQuery( $conds, $opts );
 101+ if( $rows === false ){
102102 $this->doHeader( $opts );
103103 return;
104104 }
105105
106 - while( $row = $res->fetchObject() ){
107 - $rows[] = $row;
 106+ foreach( $rows as $row ) {
108107 if ( !$feedFormat ) {
109108 // User page and talk links
110109 $batch->add( NS_USER, $row->rc_user_text );
111110 $batch->add( NS_USER_TALK, $row->rc_user_text );
112111 }
113 -
114112 }
115 - $res->free();
116113
117114 if ( $feedFormat ) {
118115 list( $feed, $feedObj ) = $this->getFeedObject( $feedFormat );
@@ -120,7 +117,8 @@
121118 $batch->execute();
122119 $this->webOutput( $rows, $opts );
123120 }
124 -
 121+
 122+ $rows->free();
125123 }
126124
127125 /**

Status & tagging log