mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 00:40:12 +00:00
Rearrange Cite::listToText for performance
The two message are not needed in case there is only one element. Since fetching messages is a little expensive, I feel it's worth rearranging this code. Or not, because it seems this method is never called with one element only. Change-Id: Ie915278b41f053afe0d14a29d2aec54c98e5185e
This commit is contained in:
parent
1fe6947693
commit
8760fe5e62
|
@ -1097,18 +1097,16 @@ class Cite {
|
|||
*/
|
||||
private function listToText( $arr ) {
|
||||
$cnt = count( $arr );
|
||||
|
||||
$sep = wfMessage( 'cite_references_link_many_sep' )->inContentLanguage()->plain();
|
||||
$and = wfMessage( 'cite_references_link_many_and' )->inContentLanguage()->plain();
|
||||
|
||||
if ( $cnt === 1 ) {
|
||||
// Enforce always returning a string
|
||||
return (string)$arr[0];
|
||||
} else {
|
||||
}
|
||||
|
||||
$sep = wfMessage( 'cite_references_link_many_sep' )->inContentLanguage()->plain();
|
||||
$and = wfMessage( 'cite_references_link_many_and' )->inContentLanguage()->plain();
|
||||
$t = array_slice( $arr, 0, $cnt - 1 );
|
||||
return implode( $sep, $t ) . $and . $arr[$cnt - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the labels to pass to the
|
||||
|
|
Loading…
Reference in a new issue