Bug #16375
closedPerformance tunning : avoid low php-functions
Added by Popy no-lastname-given about 17 years ago. Updated about 14 years ago.
0%
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 |
Updated by Oliver Klee about 17 years ago
Popy, are you sure this is the right patch? It seems more to be about sql_free_result and using COUNT.
Updated by Benni Mack about 17 years ago
I like the patch. Finally a first step in getting rid of all the PHP3-made code from ten years ago ;-).
Updated by Oliver Hader about 17 years ago
- $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!
Updated by Oliver Klee about 17 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.
Updated by Popy no-lastname-given about 17 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)
Updated by Popy no-lastname-given almost 17 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 ;)
Updated by Oliver Hader almost 17 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) { ... }
Updated by Oliver Hader almost 17 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.
Updated by Oliver Hader almost 17 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).
Updated by Franz Holzinger almost 17 years ago
see also 6193 which belongs to here
Updated by Oliver Hader over 16 years ago
I'm going to modify the patch concerning to PHP5 changes in t3lib_div this weekend.
Updated by Oliver Hader over 16 years ago
I've attached a new patch which now works again with current "Trunk" (TYPO3_4-2).
Updated by Oliver Hader over 16 years ago
Committed to SVN TYPO3_4-2 (rev. 3216)