Upto 50% faster, depending on the browser.
https://gist.github.com/Krinkle/
4a22236022027af511b8d33feab0c4c2#gistcomment-
2037282
Also change confusing parameter name 'i' to 'obj' in getModuleNames().
This one can't be changed since it loops over an object, not an array.
Bug: T160953
Change-Id: I85d6348670703c7ef061ba735ea441a1fc008062
* @return {string} Hash of concatenated version hashes.
*/
function getCombinedVersion( modules ) {
* @return {string} Hash of concatenated version hashes.
*/
function getCombinedVersion( modules ) {
- var hashes = $.map( modules, function ( module ) {
+ var hashes = modules.map( function ( module ) {
return registry[ module ].version;
} );
return fnv132( hashes.join( '' ) );
return registry[ module ].version;
} );
return fnv132( hashes.join( '' ) );
* @return {Array}
*/
getModuleNames: function () {
* @return {Array}
*/
getModuleNames: function () {
- return $.map( registry, function ( i, key ) {
+ return $.map( registry, function ( obj, key ) {
// for all loading modules. If one fails, fall back to tracking each module
// separately via $.when(), this is expensive.
loading = mw.loader.using( loading ).then( null, function () {
// for all loading modules. If one fails, fall back to tracking each module
// separately via $.when(), this is expensive.
loading = mw.loader.using( loading ).then( null, function () {
- var all = $.map( loading, function ( module ) {
+ var all = loading.map( function ( module ) {
return mw.loader.using( module ).then( null, function () {
return $.Deferred().resolve();
} );
return mw.loader.using( module ).then( null, function () {
return $.Deferred().resolve();
} );