mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +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 $buffer;
|
||||||
private $offset;
|
private $offset;
|
||||||
private $endianness;
|
private $endianness;
|
||||||
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){
|
||||||
|
@ -31,7 +31,7 @@ class RakNetPacket extends Packet{
|
|||||||
public function pid(){
|
public function pid(){
|
||||||
return $this->packetID;
|
return $this->packetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get($len){
|
protected function get($len){
|
||||||
if($len <= 0){
|
if($len <= 0){
|
||||||
$this->offset = strlen($this->buffer) - 1;
|
$this->offset = strlen($this->buffer) - 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user