mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +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,17 +1097,15 @@ 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 {
|
||||
$t = array_slice( $arr, 0, $cnt - 1 );
|
||||
return implode( $sep, $t ) . $and . $arr[$cnt - 1];
|
||||
}
|
||||
|
||||
$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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue