THRIFT-1521:patches for more Performance
Client: php
Patch: D. Edler
Removes double function calls in the transport classes to strlen.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1390051 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/lib/Thrift/Transport/TMemoryBuffer.php b/lib/php/lib/Thrift/Transport/TMemoryBuffer.php
index cfe5e0e..911fab6 100644
--- a/lib/php/lib/Thrift/Transport/TMemoryBuffer.php
+++ b/lib/php/lib/Thrift/Transport/TMemoryBuffer.php
@@ -59,13 +59,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;