Task #54085
closedEpic #55070: Workpackages
Epic #55065: WP: Overall System Performance (Backend and Frontend)
Story #55078: Optimize PHP code performance in TYPO3 methods
Replace all strcmp() calls with ===
Added by Markus Klein almost 11 years ago. Updated about 7 years ago.
100%
Description
When testing for the identity of strings using the strcmp() function has worse performance than the === operator. (3-5x)
Replace all ~300 calls to strcmp() with the operator.
Attention: This is replacement only works when the return value of strcmp() is checked for being a boolean value, otherwise a string ordering is performed and the call MUST NOT be replaced!
The operator is also slower than the = operator, so use the latter one if possible.
Updated by Jo Hasenau almost 11 years ago
I will take care of it the next days - thanks for opening the issue :-)
Updated by Markus Klein almost 11 years ago
@Jo: Maybe http://forge.typo3.org/issues/54091 is relevant too.
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/25843
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/25843
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/25843
Updated by Jo Hasenau almost 11 years ago
Attention: This is replacement only works when the return value of strcmp() is checked for being zero, otherwise a string ordering is performed and the call MUST NOT be replaced!
Shouldn't it be: "is checked for being zero or not being zero"
Actually strcmp is meant to be used for sorting of strings, since it can return positive or negative values for cases when string A is "larger" or "smaller" than string B. It will return 0 when string "A" and string "B" are equal.
So any case that is just checking for the result of strcmp being TRUE or FALSE could IMHO be safely replaced.
In some cases we might have to add isset() before the === operator since NULL could be !== '' but still might have to be considered ''.
Anyway even
isset($foo) && $foo !== ''
will perform better, since it will just skip the operator in cases when $foo is NULL and it will no create any copies, so the memory footprint will be significantly smaller.
Updated by Markus Klein almost 11 years ago
I updated the description to be more precise about the boolean usage.
And it would be great to see some memory footprint in the end. The question surely is not if we have a reduction, but rather how much it finally really is. ;-)
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/25843
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/25843
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/25843
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/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 20 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 21 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 22 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 23 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 24 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 25 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 26 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 27 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 28 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Gerrit Code Review almost 11 years ago
Patch set 29 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25843
Updated by Jo Hasenau almost 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 0a761995a14e870c7a2f21547acf073c9293d856.
Updated by Ernesto Baschny almost 11 years ago
- Target version changed from next-patchlevel to 6.2.0
- Parent task changed from #52949 to #55078
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed