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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T5592, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 3592 - Unnecessary instantiation of User
Unnecessary instantiation of User
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
1.5.x
All All
: Normal normal (vote)
: ---
Assigned To: Rob Church
:
Depends on:
Blocks:
  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: ---


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

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 );

etc.
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.


Navigation
Links