r37038 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37037‎ | r37038 | r37039 >
Date:10:24, 4 July 2008
Author:nicdumz
Status:old
Tags:
Comment:
6 array_diff_* were computed twice. Compute once, and remember them instead.
Modified paths:
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LinksUpdate.php
@@ -97,11 +97,13 @@
9898
9999 # Image links
100100 $existing = $this->getExistingImages();
101 - $this->incrTableUpdate( 'imagelinks', 'il', $this->getImageDeletions( $existing ),
102 - $this->getImageInsertions( $existing ) );
103101
 102+ $imageDeletes = $this->getImageDeletions( $existing );
 103+ $imageInserts = $this->getImageInsertions( $existing );
 104+ $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes, $imageInserts );
 105+
104106 # Invalidate all image description pages which had links added or removed
105 - $imageUpdates = array_diff_key( $existing, $this->mImages ) + array_diff_key( $this->mImages, $existing );
 107+ $imageUpdates = $imageDeletions + $imageInsertions
106108 $this->invalidateImageDescriptions( $imageUpdates );
107109
108110 # External links
@@ -121,23 +123,27 @@
122124
123125 # Category links
124126 $existing = $this->getExistingCategories();
125 - $this->incrTableUpdate( 'categorylinks', 'cl', $this->getCategoryDeletions( $existing ),
126 - $this->getCategoryInsertions( $existing ) );
127127
 128+ $categoryDeletes = $this->getCategoryDeletions( $existing );
 129+ $categoryInserts = $this->getCategoryInsertions( $existing );
 130+
 131+ $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes, $categoryInserts );
 132+
128133 # Invalidate all categories which were added, deleted or changed (set symmetric difference)
129 - $categoryInserts = array_diff_assoc( $this->mCategories, $existing );
130 - $categoryDeletes = array_diff_assoc( $existing, $this->mCategories );
131134 $categoryUpdates = $categoryInserts + $categoryDeletes;
132135 $this->invalidateCategories( $categoryUpdates );
133136 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
134137
135138 # Page properties
136139 $existing = $this->getExistingProperties();
137 - $this->incrTableUpdate( 'page_props', 'pp', $this->getPropertyDeletions( $existing ),
138 - $this->getPropertyInsertions( $existing ) );
139140
 141+ $propertiesDeletes = $this->getPropertiesDeletions( $existing );
 142+ $propertiesInserts = $this->getPropertiesInsertions( $existing );
 143+
 144+ $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes, $propertiesInserts );
 145+
140146 # Invalidate the necessary pages
141 - $changed = array_diff_assoc( $existing, $this->mProperties ) + array_diff_assoc( $this->mProperties, $existing );
 147+ $changed = $propertiesDeletes + $propertiesInserts;
142148 $this->invalidateProperties( $changed );
143149
144150 # Refresh links of all pages including this page

Status & tagging log