jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/359654 )
Change subject: Performance: Shortcut Language::truncate if there's no need to
truncate
......................................................................
Performance: Shortcut Language::truncate if there's no need to truncate
Return the unmodified string if there's no need to truncate it without
doing a not-so-trivial round of getting a message from the message
cache.
Change-Id: I11ac88672aeb9d1c4f5709b79ad2d17223bd64d8
---
M languages/Language.php
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Umherirrender: Looks good to me, approved
Fomafix: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/languages/Language.php b/languages/Language.php
index fdf2d05..27c9faf 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -3489,15 +3489,16 @@
* @return string
*/
function truncate( $string, $length, $ellipsis = '...', $adjustLength =
true ) {
+ # Check if there is no need to truncate
+ if ( strlen( $string ) <= abs( $length ) ) {
+ return $string; // no need to truncate
+ }
# Use the localized ellipsis character
if ( $ellipsis == '...' ) {
$ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this
)->escaped();
}
- # Check if there is no need to truncate
if ( $length == 0 ) {
return $ellipsis; // convention
- } elseif ( strlen( $string ) <= abs( $length ) ) {
- return $string; // no need to truncate
}
$stringOriginal = $string;
# If ellipsis length is >= $length then we can't apply
$adjustLength
--
To view, visit https://gerrit.wikimedia.org/r/359654
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I11ac88672aeb9d1c4f5709b79ad2d17223bd64d8
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Martineznovo <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Fomafix <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits