You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "D. Edler (Updated) (JIRA)" <ji...@apache.org> on 2012/02/23 10:43:52 UTC
[jira] [Updated] (THRIFT-1521) Two patches for more Performance
[ https://issues.apache.org/jira/browse/THRIFT-1521?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
D. Edler updated THRIFT-1521:
-----------------------------
Attachment: patch.diff
Fixes Performance.
> Two patches for more Performance
> --------------------------------
>
> Key: THRIFT-1521
> URL: https://issues.apache.org/jira/browse/THRIFT-1521
> Project: Thrift
> Issue Type: Improvement
> Components: PHP - Library
> Affects Versions: 0.6.1, 0.7, 0.8, 0.9, 1.0, 1.1
> Reporter: D. Edler
> Attachments: patch.diff
>
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> There are two double Function calls to strlen, which can easily prevented.
> Index: trunk/lib/php/src/transport/TTransport.php
> ===================================================================
> --- trunk/lib/php/src/transport/TTransport.php (revision 1292723)
> +++ trunk/lib/php/src/transport/TTransport.php (working copy)
> @@ -81,7 +81,7 @@
> public function readAll($len) {
> // return $this->read($len);
>
> - $data = '';
> + $data = $this->read($len - $got);
> $got = 0;
> while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
> $data .= $this->read($len - $got);
> Index: trunk/lib/php/src/transport/TMemoryBuffer.php
> ===================================================================
> --- trunk/lib/php/src/transport/TMemoryBuffer.php (revision 1292723)
> +++ trunk/lib/php/src/transport/TMemoryBuffer.php (working copy)
> @@ -54,13 +54,15 @@
> }
>
> public function read($len) {
> - if (TStringFuncFactory::create()->strlen($this->buf_) === 0) {
> + $bufLength = TStringFuncFactory::create()->strlen($this->buf_);
> +
> + if ($bufLength === 0) {
> throw new TTransportException('TMemoryBuffer: Could not read ' .
> $len . ' bytes from buffer.',
> TTransportException::UNKNOWN);
> }
>
> - if (TStringFuncFactory::create()->strlen($this->buf_) <= $len) {
> + if ($bufLength <= $len) {
> $ret = $this->buf_;
> $this->buf_ = '';
> return $ret;
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira