You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "jiang dongliang (JIRA)" <ji...@apache.org> on 2016/03/10 04:36:40 UTC
[jira] [Updated] (THRIFT-3732) performance optimization
[ https://issues.apache.org/jira/browse/THRIFT-3732?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jiang dongliang updated THRIFT-3732:
------------------------------------
Description:
It's not necessary to get the instance inside the while loop.
for example file TTransport.php
public function readAll($len)
{
// return $this->read($len);
$data = '';
$got = 0;
/** original
while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
*/
$factory = TStringFuncFactory::create();
while (($got = $factory->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
return $data;
}
was:
file TTransport.php
public function readAll($len)
{
// return $this->read($len);
$data = '';
$got = 0;
/** original
while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
*/
$factory = TStringFuncFactory::create();
while (($got = $factory->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
return $data;
}
> performance optimization
> ------------------------
>
> Key: THRIFT-3732
> URL: https://issues.apache.org/jira/browse/THRIFT-3732
> Project: Thrift
> Issue Type: Improvement
> Components: PHP - Library
> Reporter: jiang dongliang
>
> It's not necessary to get the instance inside the while loop.
> for example file TTransport.php
> public function readAll($len)
> {
> // return $this->read($len);
> $data = '';
> $got = 0;
> /** original
> while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
> $data .= $this->read($len - $got);
> }
> */
> $factory = TStringFuncFactory::create();
> while (($got = $factory->strlen($data)) < $len) {
> $data .= $this->read($len - $got);
> }
> return $data;
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)