mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Faster NBT parsing
This commit is contained in:
parent
98c0dfef43
commit
5f53f61121
@ -26,18 +26,21 @@ class NBT implements ArrayAccess{
|
||||
private $buffer;
|
||||
private $offset;
|
||||
private $endianness;
|
||||
private $data;
|
||||
|
||||
private $data;
|
||||
|
||||
public function get($len){
|
||||
if($len < 0){
|
||||
if($len <= 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
return "";
|
||||
}
|
||||
if($len === true){
|
||||
}elseif($len === true){
|
||||
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){
|
||||
|
@ -31,7 +31,7 @@ class RakNetPacket extends Packet{
|
||||
public function pid(){
|
||||
return $this->packetID;
|
||||
}
|
||||
|
||||
|
||||
protected function get($len){
|
||||
if($len <= 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user