mw.inspect: Include templates and messages in size

Currently, mw.inspect#getModuleSize omits the size of templates and
messages while calculating a ResourceLoader module's size despite them
being included in the module's definition.

Change-Id: Ib8d52c901a8e1656b8b6996762bfbff3af16a834
This commit is contained in:
Sam Smith 2017-02-24 10:08:07 +00:00 committed by Sam Smith
parent c10cdec089
commit ce2652c9ec

View file

@ -95,6 +95,15 @@
payload += $.byteLength( module.script.toString() );
}
// Tally templates and messages. Calculate their JSON size so that keys
// are included in the module size - in the case of messages, keys can be
// longer than values - and so that empty objects are also included.
$.each( [ module.templates, module.messages ], function ( i, object ) {
if ( object ) {
payload += $.byteLength( JSON.stringify( object ) );
}
} );
return payload;
},