On 11/25/07, aaron(a)svn.wikimedia.org
<aaron(a)svn.wikimedia.org> wrote:
+ /**
+ * As we use the same small set of messages in various methods and that
+ * they are called often, we call them once and save them in $this->message
+ */
+ function preCacheMessages() {
+ // Precache various messages
+ if( !isset( $this->message ) ) {
+ $this->message['last'] = wfMsgExt( 'last',
array( 'escape') );
+ }
+ }
As a general remark (I've seen this technique in more than one special
page's code), do we really need this? Doesn't MessageCache handle
local message caching anyway?
wfMsg() profiles at ~200us, so it would save a little bit of time if
you're going to be using the message lots of times. I've usually found
local variables to be sufficient as a temporary cache, maybe there's some
special reason in this case why it needs to be in the object.
-- Tim Starling