User "Dantman" posted a comment on MediaWiki.r93515.
Full URL:
https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Special:Code/MediaWiki/93515#c20298
Commit summary:
mediawiki.js request() caching deep level object member access.
- Instead of requesting index 0 of dependancies-argument, and the value of that
of the registry, and the dependancies object in that of which we read the
length property is very deep. Even worse when doing that both in the head and
in the body of a for()-loop.
- Instead caching reference access to dependancies object of the registry item.
- Plus a simple by-value of the length property
Comment:
...and what happened to the standard arr.push(); Same for the other line, the
more readable way to do this would be:
<source lang=javascript>
for ( var n = 0, regItemDepLen = regItemDeps.length; n < regItemDepLen; n++ ) {
dependencies.push(regItemDeps[n]);
}
</source>
..though frankly, you could do this with either of these:
<source lang=javascript>
dependencies.push.apply(dependencies, regItemDeps); // efficient but perhaps a
little advanced to read; I like to create an .append() method to make it
readable.
dependencies = dependencies.concat(regItemDeps); // less efficient, more
readable, may have side effects if the dependencies array is mentioned
elsewhere.
</code>
Maybe something like mw.util.Array.append?
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview