Task #54500
closedUse arrays in str_replace() calls
100%
Description
Multiple consecutive calls to str_replace can be replaced with a single call if the subject is the same.
This will speed up the replacement and in some cases has the benefit of being able to return or use the result of the str_replace directly without creating an intermediate variable.
Bad:
$lala = 'something';
$lala = str_replace('so', 'the', $lala);
$lala = str_replace('me', ' ', $lala);
$lala = str_replace('thing', 'other', $lala);
Good:
$lala = str_replace(
array('so', 'me', 'thing'),
array('the', ' ', 'other'),
'something'
);
Updated by Gerrit Code Review almost 11 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Gerrit Code Review almost 11 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Gerrit Code Review almost 11 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Gerrit Code Review almost 11 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Mathias Schreiber almost 11 years ago
IIRC we are not to change adodb code since it if 3rd party.
It would be awesome if you could just revert those changes.
Apart from that... great catch.
Updated by Gerrit Code Review almost 11 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Gerrit Code Review almost 11 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Gerrit Code Review almost 11 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26481
Updated by Michiel Roos almost 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ff2933b80b0b1cca49bc4360da80ac9d186dd320.