Commit 9f950cb1 authored by Etienne CHAMPETIER's avatar Etienne CHAMPETIER

ZP-797 WBXMLDecoder->getTermStr(): use stream_get_line().

Released under the Affero GNU General Public License (AGPL) version 3.

while importing 1340 contacts on an android 4.4,
getTermStr was called 12021 times (and getByte 216005 times)
This simplify greatly the code and improve performance
parent 6e5d3e83
...@@ -578,17 +578,12 @@ class WBXMLDecoder extends WBXMLDefs { ...@@ -578,17 +578,12 @@ class WBXMLDecoder extends WBXMLDefs {
* @return string * @return string
*/ */
private function getTermStr() { private function getTermStr() {
$str = ""; // there is no unlimited "length" for stream_get_line,
while(1) { // so we use a huge value for "length" param (1Gb)
$in = $this->getByte(); // (0 == PHP_SOCK_CHUNK_SIZE (8192))
// internaly php read at most PHP_SOCK_CHUNK_SIZE at a time,
if($in == 0) // so we can use a huge value for "length" without problem
break; return stream_get_line($this->in, 1073741824, "\0");
else
$str .= chr($in);
}
return $str;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment