Project

General

Profile

Actions

Bug #16375

closed

Performance tunning : avoid low php-functions

Added by Popy no-lastname-given over 16 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
-
Target version:
-
Start date:
2007-07-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Using foreach instead of while (list() = each())
Using strpos instead of strstr for conditions

(issue imported from #M6037)


Files

class.t3lib_div.php.diff (386 Bytes) class.t3lib_div.php.diff Administrator Admin, 2007-07-27 14:36
class.t3lib_div.php.2.diff (11.9 KB) class.t3lib_div.php.2.diff Administrator Admin, 2007-07-27 17:19
class.t3lib_div.php.corrected.diff (11.9 KB) class.t3lib_div.php.corrected.diff Administrator Admin, 2007-08-17 10:06
0006037.patch (26.7 KB) 0006037.patch Administrator Admin, 2007-08-19 13:35
0006037_v4.patch (17 KB) 0006037_v4.patch Administrator Admin, 2008-02-16 13:26
Actions #1

Updated by Oliver Klee over 16 years ago

Popy, are you sure this is the right patch? It seems more to be about sql_free_result and using COUNT.

Actions #2

Updated by Popy no-lastname-given over 16 years ago

You're right ^^

Actions #3

Updated by Benni Mack over 16 years ago

I like the patch. Finally a first step in getting rid of all the PHP3-made code from ten years ago ;-).

Actions #4

Updated by Oliver Hader over 16 years ago

I also like this patch. It makes the whole thing also more readable/understandable. But the are some small typos in the patch, e.g.:
  • $vval vs. $val
  • $kAkey vs. $Akey

The "\\" and "//" in t3lib_div::validPathStr could possibly be put into to the preg_match.

Thanks Popy for the patch!

Actions #5

Updated by Oliver Klee over 16 years ago

function inList($list,$item) {
- return strstr(','.$list.',', ','.$item.',') ? true : false;
+ return strpos(' ,'.$list.',', ','.$item.',') ? true : false;

Is this correct? Usually, the result of strpos needs to be compared with false to test for the existence of one string in another.

Actions #6

Updated by Popy no-lastname-given over 16 years ago

No because i did add a space befire the first comma (added to $list) so if the found item is the first, strpos will return 1 (and not 0 which have to be comparated to false)

Actions #7

Updated by Popy no-lastname-given over 16 years ago

@ Oliver Hader : I did correct my typos and attach the file. It's first time you agree with me, that's a nice day ;)

Actions #8

Updated by Oliver Hader over 16 years ago

;-)

I have an additional issue for TYPO3 4.2 which will require PHP 5.2:
The foreach loops can be improved by factor 1.5-2 on using references, e.g.
foreach ($array as $key => <b>&</b>$value) { ... }

Actions #9

Updated by Oliver Hader over 16 years ago

I'm going to change the foreach reference thingy, test each of the changes again and then finally post it to the Core-List.

Actions #10

Updated by Oliver Hader over 16 years ago

I reviewed Popy's patch and additionally changed some things (e.g. with the foreach references). I left the function t3lib_div::trimExplode() untouched because there is already a RFC in the Core-List (see bug #15834).

Actions #11

Updated by Franz Holzinger over 16 years ago

see also 6193 which belongs to here

Actions #12

Updated by Ingo Renner about 16 years ago

Any news here for TYPO3 4.2?

Actions #13

Updated by Oliver Hader about 16 years ago

I'm going to modify the patch concerning to PHP5 changes in t3lib_div this weekend.

Actions #14

Updated by Oliver Hader about 16 years ago

I've attached a new patch which now works again with current "Trunk" (TYPO3_4-2).

Actions #15

Updated by Oliver Hader about 16 years ago

Committed to SVN TYPO3_4-2 (rev. 3216)

Actions

Also available in: Atom PDF