[TYPO3-core] RFC: feature #2883
Wolfgang Klinger
wolfgang at stufenlos.net
Mon Mar 20 14:36:38 CET 2006
*hiya!*
type: feature / speed improvement
BT reference: http://bugs.typo3.org/view.php?id=2883
This is a speed improvement for trimExplode.
-----------------
Result *old*: 39.97
-----------------
Result *new*: 28.69
-----------------
(500 iterations)
kind regards
Wolfgang
-------------- next part --------------
--- TYPO3core/t3lib/class.t3lib_div.php 2006-03-20 14:00:57.000000000 +0100
+++ TYPO3core_testing/t3lib/class.t3lib_div.php 2006-03-20 14:23:10.000000000 +0100
@@ -1421,15 +1421,11 @@
* @return array Exploded values
*/
function trimExplode($delim, $string, $onlyNonEmptyValues=0) {
- $temp = explode($delim,$string);
- $newtemp=array();
- while(list($key,$val)=each($temp)) {
- if (!$onlyNonEmptyValues || strcmp('',trim($val))) {
- $newtemp[]=trim($val);
- }
+ if ($onlyNonEmptyValues) {
+ return array_diff(array_map('trim', explode($delim, $string)), array());
+ } else {
+ return array_map('trim', explode($delim, $string));
}
- reset($newtemp);
- return $newtemp;
}
/**
More information about the TYPO3-team-core
mailing list