#88754Codesmell GeneralUtility::trimExplode()
Description
Optimize Coding of GeneralUtility:trimExplode. The Foreach-loop and the slice-Operation seems not good in the current method.
I guess, the following-code is faster.
public static function trimExplode($delim, $string, $removeEmptyValues = false, $limit = 0) {
if ($limit>0) {
$result = array_map('trim',
explode($delim, $string,$limit));
} else {
$result = array_map('trim',
explode($delim, $string));
}
if ($removeEmptyValues === true) {
$result = array_filter($result, function($k){
return $k !== ''
});
}
return $result;
}
The code-example and the performance is not tested yet.
Perhaps: If the $removeEmptyValues ist related to the php-Function empty(), then the filter-function is obsolete.
@ $result = array_filter($result) @
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.