mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
Check if the array contents are already the same, massive performance improvement for Anvil in a lot of cases
This commit is contained in:
parent
7de7593b89
commit
e4c889ae16
@ -34,6 +34,7 @@ class ChunkUtils{
|
|||||||
*/
|
*/
|
||||||
public static final function reorderByteArray(string $array) : string{
|
public static final function reorderByteArray(string $array) : string{
|
||||||
$result = str_repeat("\x00", 4096);
|
$result = str_repeat("\x00", 4096);
|
||||||
|
if($array !== $result){
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$zM = 0;
|
$zM = 0;
|
||||||
$yM = 0;
|
$yM = 0;
|
||||||
@ -47,6 +48,8 @@ class ChunkUtils{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +63,8 @@ class ChunkUtils{
|
|||||||
*/
|
*/
|
||||||
public static final function reorderNibbleArray(string $array, string $commonValue = "\x00") : string{
|
public static final function reorderNibbleArray(string $array, string $commonValue = "\x00") : string{
|
||||||
$result = str_repeat($commonValue, 2048);
|
$result = str_repeat($commonValue, 2048);
|
||||||
|
|
||||||
|
if($array !== $result){
|
||||||
$i = 0;
|
$i = 0;
|
||||||
for($x = 0; $x < 8; ++$x){
|
for($x = 0; $x < 8; ++$x){
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
@ -80,6 +85,8 @@ class ChunkUtils{
|
|||||||
}
|
}
|
||||||
$i += 128;
|
$i += 128;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user