Project

General

Profile

Actions

Task #54085

closed

Epic #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 over 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Performance
Target version:
Start date:
2013-11-29
Due date:
% Done:

100%

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

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.


Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Task #54265: Use (int) instead of intval() or (integer)ClosedJo Hasenau2013-12-07

Actions
Related to TYPO3 Core - Task #54517: Replace substr() and strpos() with GeneralUtility::isFirstPartOfString when it makes senseRejectedJo Hasenau2013-12-19

Actions
Related to TYPO3 Core - Bug #56248: You can not add new records (TCA) in the edit modeClosed2014-02-24

Actions
Related to TYPO3 Core - Bug #58525: First usergroup from BE-user no longer applied to new pagesClosed2014-05-05

Actions
Related to TYPO3 Core - Task #56393: creation on new pages have broken permissions (perms_groupid set wrong)Closed2014-02-27

Actions
Actions #1

Updated by Jo Hasenau over 10 years ago

I will take care of it the next days - thanks for opening the issue :-)

Actions #2

Updated by Markus Klein over 10 years ago

@Jo: Maybe http://forge.typo3.org/issues/54091 is relevant too.

Actions #3

Updated by Gerrit Code Review over 10 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

Actions #4

Updated by Gerrit Code Review over 10 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

Actions #5

Updated by Gerrit Code Review over 10 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

Actions #6

Updated by Jo Hasenau over 10 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.

Actions #7

Updated by Markus Klein over 10 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. ;-)

Actions #8

Updated by Gerrit Code Review over 10 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

Actions #9

Updated by Gerrit Code Review over 10 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

Actions #10

Updated by Gerrit Code Review over 10 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

Actions #11

Updated by Gerrit Code Review over 10 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

Actions #12

Updated by Gerrit Code Review over 10 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

Actions #13

Updated by Gerrit Code Review over 10 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

Actions #14

Updated by Gerrit Code Review over 10 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

Actions #15

Updated by Gerrit Code Review over 10 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

Actions #16

Updated by Gerrit Code Review over 10 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

Actions #17

Updated by Gerrit Code Review over 10 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

Actions #18

Updated by Gerrit Code Review over 10 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

Actions #19

Updated by Gerrit Code Review over 10 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

Actions #20

Updated by Gerrit Code Review over 10 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

Actions #21

Updated by Gerrit Code Review over 10 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

Actions #22

Updated by Gerrit Code Review over 10 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

Actions #23

Updated by Gerrit Code Review over 10 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

Actions #24

Updated by Gerrit Code Review over 10 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

Actions #25

Updated by Gerrit Code Review over 10 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

Actions #26

Updated by Gerrit Code Review over 10 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

Actions #27

Updated by Gerrit Code Review over 10 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

Actions #28

Updated by Gerrit Code Review over 10 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

Actions #29

Updated by Gerrit Code Review over 10 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

Actions #30

Updated by Gerrit Code Review over 10 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

Actions #31

Updated by Gerrit Code Review over 10 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

Actions #32

Updated by Gerrit Code Review over 10 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

Actions #33

Updated by Gerrit Code Review over 10 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

Actions #34

Updated by Jo Hasenau over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #35

Updated by Ernesto Baschny about 10 years ago

  • Target version changed from next-patchlevel to 6.2.0
  • Parent task changed from #52949 to #55078
Actions #36

Updated by Markus Klein almost 10 years ago

Regression in #56393

Actions #37

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF