mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-27 05:13:46 +00:00
More nibble array re-ordering optimisation
This commit is contained in:
parent
dd01407dd4
commit
5025b4aba1
@ -714,24 +714,19 @@ class GenericChunk implements Chunk{
|
|||||||
public static final function reorderNibbleArray(string $array) : string{
|
public static final function reorderNibbleArray(string $array) : string{
|
||||||
$result = str_repeat("\x00", 2048);
|
$result = str_repeat("\x00", 2048);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($x = 0; $x < 8; ++$x){
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
$zx = (($z << 3) | ($x >> 1));
|
$zx = (($z << 3) | $x);
|
||||||
for($y = 0; $y < 8; ++$y){
|
for($y = 0; $y < 8; ++$y){
|
||||||
$j = (($y << 8) | $zx);
|
$j = (($y << 8) | $zx);
|
||||||
$byte = ord($array{$j});
|
$result{$i++} = chr((ord($array{$j}) & 0x0f) | (ord($array{$j | 0x80}) << 4));
|
||||||
|
|
||||||
if(($x & 1) === 0){
|
|
||||||
$current = ($byte & 0x0f);
|
|
||||||
$byte = ord($array{$j | 0x80});
|
|
||||||
$current |= ($byte << 4);
|
|
||||||
}else{
|
|
||||||
$current = ($byte >> 4);
|
|
||||||
$byte = ord($array{$j | 0x80});
|
|
||||||
$current |= ($byte & 0xf0);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$result{$i++} = chr($current);
|
for($z = 0; $z < 16; ++$z){
|
||||||
|
$zx = (($z << 3) | $x);
|
||||||
|
for($y = 0; $y < 8; ++$y){
|
||||||
|
$j = (($y << 8) | $zx);
|
||||||
|
$result{$i++} = chr((ord($array{$j}) >> 4) | (ord($array{$j | 0x80}) & 0xf0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user