mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 11:18:52 +00:00
Faster NBT parsing
This commit is contained in:
parent
98c0dfef43
commit
5f53f61121
@ -29,15 +29,18 @@ class NBT implements ArrayAccess{
|
|||||||
private $data;
|
private $data;
|
||||||
|
|
||||||
public function get($len){
|
public function get($len){
|
||||||
if($len < 0){
|
if($len <= 0){
|
||||||
$this->offset = strlen($this->buffer) - 1;
|
$this->offset = strlen($this->buffer) - 1;
|
||||||
return "";
|
return "";
|
||||||
}
|
}elseif($len === true){
|
||||||
if($len === true){
|
|
||||||
return substr($this->buffer, $this->offset);
|
return substr($this->buffer, $this->offset);
|
||||||
}
|
}
|
||||||
$this->offset += $len;
|
|
||||||
return substr($this->buffer, $this->offset - $len, $len);
|
$buffer = b"";
|
||||||
|
for(; $len > 0; --$len, ++$this->offset){
|
||||||
|
$buffer .= @$this->buffer{$this->offset};
|
||||||
|
}
|
||||||
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put($v){
|
public function put($v){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user