[TYPO3-core] RFC #11808 : [Feature]: Increase performance using mbstring in t3lib_cs->crop
Martin Kutschker
masi-no at spam-typo3.org
Fri Aug 28 08:37:48 CEST 2009
Steffen Kamper schrieb:
> Hi,
>
> here is a new patch with
> * created against root (please look that patches always are generated
> against root)
> * corrected phpDoc
> * used protected (this function shouldn't be called from outside)
>
> so +1 by reading, testing follows now.
Yet there is an error: mb_strlen() is called without the charset.
Nitpickings:
intval($len) is called twice if mbstring is not used.
A separate function is not justified. I guess that all the speed gain is
lost by the additional function call. Other library calls are inline as
well.
My suggestion (in spirit of the rest of t3lib_cs):
function crop($charset,$string,$len,$crop='') {
if (intval($len) == 0) return $string;
// Timo Schmidt <timo.schmidt at aoemedia.de>
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] ==
'mbstring') {
mb_strlen($string, $charset) < $len) {
return $string;
}
if ($len > 0) {
return mb_substr($string, 0, $len, $charset) . $crop;
} else {
return $crop . mb_substr($string, $len, mb_strlen($string, $charset),
$charset);
}
}
// ...
}
Masi
More information about the TYPO3-team-core
mailing list