resourceloader: Move FILTER_NOMIN annotation to the beginning of output

This allows ResourceLoader::filter() to handle this case slightly
faster, since it searches for this annotation from the beginning.
In practice this is a negligible performance optimization, but let's
set a good example for the future.

Also tweak the comments and whitespace:
* Move comment about the FILTER_NOMIN from doc comment to code comment,
  it's an implementation detail and not meant for public documentation
* Remove duplicated documentation from the parent class
* Change whitespace to be identical in both cases

Change-Id: I624914ff28d903027ba58710708ccc3c66af9e24
This commit is contained in:
Bartosz Dziewoński 2018-01-30 12:12:46 +01:00 committed by Krinkle
parent 1e946e8e65
commit a129d68344
2 changed files with 7 additions and 8 deletions

View file

@ -51,10 +51,12 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule {
* @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
return Xml::encodeJsCall( 'mw.user.options.set',
// Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
return ResourceLoader::FILTER_NOMIN . Xml::encodeJsCall(
'mw.user.options.set',
[ $context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS ) ],
ResourceLoader::inDebugMode()
) . ResourceLoader::FILTER_NOMIN;
);
}
/**

View file

@ -48,19 +48,16 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
}
/**
* Generate the JavaScript content of this module.
*
* Add FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
*
* @param ResourceLoaderContext $context
* @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
return Xml::encodeJsCall(
// Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
return ResourceLoader::FILTER_NOMIN . Xml::encodeJsCall(
'mw.user.tokens.set',
[ $this->contextUserTokens( $context ) ],
ResourceLoader::inDebugMode()
) . ResourceLoader::FILTER_NOMIN;
);
}
/**