Project

General

Profile

Actions

Task #55198

closed

Epic #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

Added by Jo Hasenau over 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Performance
Target version:
Start date:
2014-01-21
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
Sprint Focus:

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:

  1. It must not be replaced when there is a limit in the original method call
  2. It must not be replaced when there is no foreach loop making use of the array immediately after the method call
  3. It must be replaced by at least a trim within the following loop
  4. 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
Actions

Also available in: Atom PDF