r25526 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25525‎ | r25526 | r25527 >
Date:08:11, 5 September 2007
Author:david
Status:old
Tags:
Comment:
similar caching by id. Threads::where is now only called twice per talk page.
Modified paths:
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -771,7 +771,8 @@
772772 static $VALID_CHANGE_TYPES = array(self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT,
773773 self::CHANGE_REPLY_CREATED, self::CHANGE_NEW_THREAD, self::CHANGE_DELETED, self::CHANGE_UNDELETED);
774774
775 - static $loadedThreads = array();
 775+ static $cache_by_root = array();
 776+ static $cache_by_id = array();
776777
777778 static $thread_children = array();
778779
@@ -890,11 +891,10 @@
891892 }
892893
893894 self::$cache_by_root[$thread->root()->getID()] = $thread;
 895+ self::$cache_by_id[$thread->id()] = $thread;
894896 }
895897 return $top_level_threads;
896898 }
897 -
898 - static $cache_by_root = array();
899899
900900 private static function databaseError( $msg ) {
901901 // TODO tie into MW's error reporting facilities.
@@ -921,8 +921,8 @@
922922 }
923923
924924 static function withId( $id ) {
925 - if( array_key_exists( $id, Threads::$loadedThreads ) ) {
926 - return Threads::$loadedThreads[ $id ];
 925+ if( array_key_exists( $id, self::$cache_by_id ) ) {
 926+ return self::$cache_by_id[$id];
927927 }
928928
929929 $ts = Threads::where( array('thread.thread_id' => $id ) );

Status & tagging log