Last modified: 2010-05-15 15:37:40 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 3592 - Unnecessary instantiation of User
Unnecessary instantiation of User
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
All All
: Normal normal (vote)
: ---
Assigned To: Rob Church
Depends on:
  Show dependency treegraph
Reported: 2005-10-04 00:19 UTC by Johannes Ernst
Modified: 2010-05-15 15:37 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Patch containing the proposed changes (633 bytes, patch)
2005-10-04 10:17 UTC, Rob Church

Description Johannes Ernst 2005-10-04 00:19:53 UTC
This is very minor, but might save a few femtoseconds.

User.php, line 53 allocates a new User object, which isn't used until line 74.
There are several paths where control may return from the method before that, in
which case this relatively heavy object has been allocated unnecessarily. 

Remedy: move line 53

$u = new User();

to before line 74, making it

$u = new User();
$u->setName( $canonicalName );

Comment 1 Rob Church 2005-10-04 10:17:06 UTC
Created attachment 935 [details]
Patch containing the proposed changes

I've proposed a patch here, although I can see why this was done - it's good
practise to declare variables and objects at the top of your functions. Then
again, PHP is much more lenient with respect to variables, and even a small
performance gain could be worth it.
Comment 2 Rob Church 2005-10-04 10:18:28 UTC
(Patch is for CVS HEAD version)
Comment 3 Johannes Ernst 2005-10-06 17:37:35 UTC
still present in 1.5.0
Comment 4 Tom Gilder 2005-10-06 23:16:39 UTC
Fixed in CVS HEAD
Comment 5 Rob Church 2005-10-06 23:23:24 UTC
I'll sort out a patch for the 1.5 branch soon.

Note You need to log in before you can comment on or make changes to this bug.