Edit report at https://pear.php.net/bugs/bug.php?id=19697&edit=1
ID: 19697
Updated by: daniel.oconnor@gmail.com
Reported By: michiel at ingoedebanen dot nl
Summary: calling str_replace unneeded uses too much memory
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: DB_DataObject
Operating System: Linux
Package Version: 1.10.0
PHP Version: 5.3.13
Roadmap Versions:
New Comment:
-Type: Bug
+Type: Feature/Change Request
Previous Comments:
------------------------------------------------------------------------
[2012-11-09 12:47:15] leening
Added #patch bug:19697;patch:DataObject.php.diff;revision:1352465235;.
------------------------------------------------------------------------
[2012-11-09 12:46:27] leening
Description:
------------
str_replace is called twice in both fetch() and fetchrow()
this is done for all keys in the result, even though they might not
contain a '.' or a ' '
since str_replace is memory expensive (consumes it), it is better to
check if the str_replace is actually needed by doing a strpos()
Test script:
---------------
The test was performed with xdebug (tracing memory usage) when
retrieving around 300-500 rows using 5 different kinds of classes.
Consider the following output:
before patch:
function #calls time memory
-----------------------------------------------
str_replace 172389 4.7536 110539952
after patch:
function #calls time memory
-----------------------------------------------
str_replace 13120 0.3583 4722288
Expected result:
----------------
That str_replace would not have consumed so much memory, but it really
adds up when you call it 170k times
------------------------------------------------------------------------