Task #55198
closedEpic #55070: Workpackages
Epic #55065: WP: Overall System Performance (Backend and Frontend)
Story #55078: Optimize PHP code performance in TYPO3 methods
Replace trimExplode + foreach with explode + trim within foreach
100%
Description
There are lots of methods making use of the costly trimExplode method using a foreach loop on the exploded array immediately after the method call.
The result is an array_map plus at least one (sometimes a second) foreach loop over the array of exploded items, one (or two) inside the trimExplode and one outside over the resulting array. Performancewise foreach is not just faster in most of the cases but has a much smaller memory footprint, so it would be a good idea to just stay with trimExplode when this is useful and necessary.
Since most of the cases don't make use of the limit parameter of trimExplode, we should replace any call to that method based on the following rules:
- It must not be replaced when there is a limit in the original method call
- It must not be replaced when there is no foreach loop making use of the array immediately after the method call
- It must be replaced by at least a trim within the following loop
- It must be replaced by a trim AND a check for empty values within the following loop, when the third parameter was set to TRUE before