Changeset View
Changeset View
Standalone View
Standalone View
src/utils/PhutilRope.php
Context not available. | |||||
* @return this | * @return this | ||||
*/ | */ | ||||
public function append($string) { | public function append($string) { | ||||
if (!strlen($string)) { | if (!@strlen($string)) { | ||||
return $this; | return $this; | ||||
} | } | ||||
$len = strlen($string); | $len = @strlen($string); | ||||
$this->length += $len; | $this->length += $len; | ||||
if ($len <= $this->segmentSize) { | if ($len <= $this->segmentSize) { | ||||
$this->buffers[] = $string; | $this->buffers[] = $string; | ||||
} else { | } else { | ||||
for ($cursor = 0; $cursor < $len; $cursor += $this->segmentSize) { | for ($cursor = 0; $cursor < $len; $cursor += $this->segmentSize) { | ||||
$this->buffers[] = substr($string, $cursor, $this->segmentSize); | $this->buffers[] = @substr($string, $cursor, $this->segmentSize); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
$remaining_bytes = $length; | $remaining_bytes = $length; | ||||
foreach ($this->buffers as $buf) { | foreach ($this->buffers as $buf) { | ||||
$length = strlen($buf); | $length = @strlen($buf); | ||||
if ($length <= $remaining_bytes) { | if ($length <= $remaining_bytes) { | ||||
$result[] = $buf; | $result[] = $buf; | ||||
$remaining_bytes -= $length; | $remaining_bytes -= $length; | ||||
} else { | } else { | ||||
$result[] = substr($buf, 0, $remaining_bytes); | $result[] = @substr($buf, 0, $remaining_bytes); | ||||
$remaining_bytes = 0; | $remaining_bytes = 0; | ||||
} | } | ||||
if (!$remaining_bytes) { | if (!$remaining_bytes) { | ||||
Context not available. | |||||
$remaining_bytes = $remove; | $remaining_bytes = $remove; | ||||
foreach ($this->buffers as $key => $buf) { | foreach ($this->buffers as $key => $buf) { | ||||
$len = strlen($buf); | $len = @strlen($buf); | ||||
if ($len <= $remaining_bytes) { | if ($len <= $remaining_bytes) { | ||||
unset($this->buffers[$key]); | unset($this->buffers[$key]); | ||||
$remaining_bytes -= $len; | $remaining_bytes -= $len; | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
} else { | } else { | ||||
$this->buffers[$key] = substr($buf, $remaining_bytes); | $this->buffers[$key] = @substr($buf, $remaining_bytes); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0