mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Optimized byte re-ordering
This commit is contained in:
parent
d70be232d8
commit
dd01407dd4
@ -691,12 +691,13 @@ class GenericChunk implements Chunk{
|
||||
*/
|
||||
public static final function reorderByteArray(string $array) : string{
|
||||
$result = str_repeat("\x00", 4096);
|
||||
$i = 0;
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$xz = (($x << 8) | ($z << 4));
|
||||
$zx = (($z << 4) | $x);
|
||||
for($y = 0; $y < 16; ++$y){
|
||||
$result{$xz | $y} = $array{($y << 8) | $zx};
|
||||
for($z = 0; $z < 256; $z += 16){
|
||||
$zx = ($z + $x);
|
||||
for($y = 0; $y < 4096; $y += 256){
|
||||
$result{$i} = $array{$y + $zx};
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user