Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
It's not necessary to get the instance inside the while loop.
When transport a big data, the function calls up to 17,681 times.
After the optimization, it's possible reducing to 125 times.
For example file TTransport.php
public function readAll($len)
{
// return $this->read($len);
$data = '';
$got = 0;
/** original
while (($got = TStringFuncFactory::create()->strlen($data)) < $len)
*/
$factory = TStringFuncFactory::create();
while (($got = $factory->strlen($data)) < $len) { $data .= $this->read($len - $got); }
return $data;
}